merge trunk

This commit is contained in:
Szymon Janc 2011-10-04 20:21:12 +02:00
commit 709e61a55f
19 changed files with 386 additions and 47 deletions

View file

@ -219,6 +219,7 @@ kernel = {
videoinkernel = commands/boot.c;
extra_dist = kern/i386/int.S;
extra_dist = kern/i386/realmode.S;
extra_dist = kern/i386/pc/lzma_decode.S;
extra_dist = kern/mips/cache_flush.S;

View file

@ -36,11 +36,33 @@ GRUB_MOD_LICENSE ("GPLv3+");
typedef enum
{
GRUB_UHCI_REG_USBCMD = 0x00,
GRUB_UHCI_REG_USBINTR = 0x04,
GRUB_UHCI_REG_FLBASEADD = 0x08,
GRUB_UHCI_REG_PORTSC1 = 0x10,
GRUB_UHCI_REG_PORTSC2 = 0x12
GRUB_UHCI_REG_PORTSC2 = 0x12,
GRUB_UHCI_REG_USBLEGSUP = 0xc0
} grub_uhci_reg_t;
/* R/WC legacy support bits */
#define GRUB_UHCI_LEGSUP_END_A20GATE (1 << 15)
#define GRUB_UHCI_TRAP_BY_64H_WSTAT (1 << 11)
#define GRUB_UHCI_TRAP_BY_64H_RSTAT (1 << 10)
#define GRUB_UHCI_TRAP_BY_60H_WSTAT (1 << 9)
#define GRUB_UHCI_TRAP_BY_60H_RSTAT (1 << 8)
/* Reset all legacy support - clear all R/WC bits and all R/W bits */
#define GRUB_UHCI_RESET_LEGSUP_SMI ( GRUB_UHCI_LEGSUP_END_A20GATE \
| GRUB_UHCI_TRAP_BY_64H_WSTAT \
| GRUB_UHCI_TRAP_BY_64H_RSTAT \
| GRUB_UHCI_TRAP_BY_60H_WSTAT \
| GRUB_UHCI_TRAP_BY_60H_RSTAT )
/* Some UHCI commands */
#define GRUB_UHCI_CMD_RUN_STOP (1 << 0)
#define GRUB_UHCI_CMD_HCRESET (1 << 1)
#define GRUB_UHCI_CMD_MAXP (1 << 7)
/* Important bits in structures */
#define GRUB_UHCI_LINK_TERMINATE 1
#define GRUB_UHCI_LINK_QUEUE_HEAD 2
@ -181,6 +203,11 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
if (class != 0x0c || subclass != 0x03 || interf != 0x00)
return 0;
/* Set bus master - needed for coreboot or broken BIOSes */
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
grub_pci_write_word(addr,
GRUB_PCI_COMMAND_BUS_MASTER | grub_pci_read_word(addr));
/* Determine IO base address. */
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG4);
base = grub_pci_read (addr);
@ -195,6 +222,19 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
u->iobase = base & GRUB_UHCI_IOMASK;
/* Reset PIRQ and SMI */
addr = grub_pci_make_address (dev, GRUB_UHCI_REG_USBLEGSUP);
grub_pci_write_word(addr, GRUB_UHCI_RESET_LEGSUP_SMI);
/* Reset the HC */
grub_uhci_writereg16(u, GRUB_UHCI_REG_USBCMD, GRUB_UHCI_CMD_HCRESET);
grub_millisleep(5);
/* Disable interrupts and commands (just to be safe) */
grub_uhci_writereg16(u, GRUB_UHCI_REG_USBINTR, 0);
/* Finish HC reset, HC remains disabled */
grub_uhci_writereg16(u, GRUB_UHCI_REG_USBCMD, 0);
/* Read back to be sure PCI write is done */
grub_uhci_readreg16(u, GRUB_UHCI_REG_USBCMD);
/* Reserve a page for the frame list. */
u->framelist = grub_memalign (4096, 4096);
if (! u->framelist)
@ -252,9 +292,6 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
u->td[N_TD - 2].linkptr = 0;
u->tdfree = u->td;
/* Make sure UHCI is disabled! */
grub_uhci_writereg16 (u, GRUB_UHCI_REG_USBCMD, 0);
/* Setup the frame list pointers. Since no isochronous transfers
are and will be supported, they all point to the (same!) queue
head. */
@ -285,7 +322,8 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
u->qh[N_QH - 1].linkptr = 1;
/* Enable UHCI again. */
grub_uhci_writereg16 (u, GRUB_UHCI_REG_USBCMD, 1 | (1 << 7));
grub_uhci_writereg16 (u, GRUB_UHCI_REG_USBCMD,
GRUB_UHCI_CMD_RUN_STOP | GRUB_UHCI_CMD_MAXP);
/* UHCI is initialized and ready for transfers. */
grub_dprintf ("uhci", "UHCI initialized\n");

View file

@ -139,6 +139,7 @@ make_regex (const char *start, const char *end, regex_t *regexp)
case '.':
case '(':
case ')':
case '@':
buffer[i++] = '\\';
buffer[i++] = ch;
break;

View file

@ -265,10 +265,13 @@ grub_util_get_fd_sectors (int fd, unsigned *log_secsize)
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
if (ioctl (fd, DIOCGSECTORSIZE, &sector_size))
goto fail;
# elif defined(__NetBSD__)
sector_size = label.d_secsize;
# else
if (ioctl (fd, BLKSSZGET, &sector_size))
# endif
goto fail;
# endif
if (sector_size & (sector_size - 1) || !sector_size)
goto fail;
@ -1838,6 +1841,9 @@ grub_util_biosdisk_is_floppy (grub_disk_t disk)
struct stat st;
int fd;
if (disk->dev != &grub_util_biosdisk_dev)
return 0;
fd = open (map[disk->id].device, O_RDONLY);
/* Shouldn't happen. */
if (fd == -1)

View file

@ -224,7 +224,11 @@ char *
canonicalize_file_name (const char *path)
{
char *ret;
#ifdef PATH_MAX
#ifdef __MINGW32__
ret = xmalloc (PATH_MAX);
if (!_fullpath (ret, path, PATH_MAX))
return NULL;
#elif defined (PATH_MAX)
ret = xmalloc (PATH_MAX);
if (!realpath (path, ret))
return NULL;

View file

@ -188,7 +188,7 @@ grub_machine_init (void)
}
else
{
grub_arch_memsize = (totalmem >> 20);
grub_arch_memsize = totalmem;
grub_arch_highmemsize = 0;
}

View file

@ -33,6 +33,8 @@
#include <grub/extcmd.h>
#include <grub/i18n.h>
#include <grub/ns8250.h>
#include <grub/bsdlabel.h>
#include <grub/crypto.h>
GRUB_MOD_LICENSE ("GPLv3+");
@ -946,6 +948,86 @@ grub_netbsd_add_modules (void)
return err;
}
/*
* Adds NetBSD bootinfo bootdisk and bootwedge. The partition identified
* in these bootinfo fields is the root device.
*/
static void
grub_netbsd_add_boot_disk_and_wedge (void)
{
grub_device_t dev;
grub_disk_t disk;
grub_partition_t part;
grub_uint32_t biosdev;
grub_uint32_t partmapsector;
struct grub_partition_bsd_disk_label *label;
grub_uint64_t buf[GRUB_DISK_SECTOR_SIZE / 8];
grub_uint8_t *hash;
grub_uint64_t ctx[(GRUB_MD_MD5->contextsize + 7) / 8];
dev = grub_device_open (0);
if (! (dev && dev->disk && dev->disk->partition))
goto fail;
disk = dev->disk;
part = disk->partition;
if (disk->dev && disk->dev->id == GRUB_DISK_DEVICE_BIOSDISK_ID)
biosdev = (grub_uint32_t) disk->id & 0xff;
else
biosdev = 0xff;
/* Absolute sector of the partition map describing this partition. */
partmapsector = grub_partition_get_start (part->parent) + part->offset;
disk->partition = part->parent;
if (grub_disk_read (disk, part->offset, 0, GRUB_DISK_SECTOR_SIZE, buf) != GRUB_ERR_NONE)
goto fail;
disk->partition = part;
/* Fill bootwedge. */
{
struct grub_netbsd_btinfo_bootwedge biw;
grub_memset (&biw, 0, sizeof (biw));
biw.biosdev = biosdev;
biw.startblk = grub_partition_get_start (part);
biw.nblks = part->len;
biw.matchblk = partmapsector;
biw.matchnblks = 1;
GRUB_MD_MD5->init (&ctx);
GRUB_MD_MD5->write (&ctx, buf, GRUB_DISK_SECTOR_SIZE);
GRUB_MD_MD5->final (&ctx);
hash = GRUB_MD_MD5->read (&ctx);
memcpy (biw.matchhash, hash, 16);
grub_bsd_add_meta (NETBSD_BTINFO_BOOTWEDGE, &biw, sizeof (biw));
}
/* Fill bootdisk if this a NetBSD disk label. */
label = (struct grub_partition_bsd_disk_label *) &buf;
if (part->partmap != NULL &&
(grub_strcmp (part->partmap->name, "netbsd") == 0) &&
label->magic == grub_cpu_to_le32 (GRUB_PC_PARTITION_BSD_LABEL_MAGIC))
{
struct grub_netbsd_btinfo_bootdisk bid;
grub_memset (&bid, 0, sizeof (bid));
bid.labelsector = partmapsector;
bid.label.type = label->type;
bid.label.checksum = label->checksum;
memcpy (bid.label.packname, label->packname, 16);
bid.biosdev = biosdev;
bid.partition = part->number;
grub_bsd_add_meta (NETBSD_BTINFO_BOOTDISK, &bid, sizeof (bid));
}
fail:
if (dev)
grub_device_close (dev);
}
static grub_err_t
grub_netbsd_boot (void)
{
@ -1607,6 +1689,8 @@ grub_cmd_netbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
grub_bsd_add_meta (NETBSD_BTINFO_CONSOLE, &cons, sizeof (cons));
}
grub_netbsd_add_boot_disk_and_wedge ();
grub_loader_set (grub_netbsd_boot, grub_bsd_unload, 0);
}

View file

@ -22,12 +22,14 @@
# define ELFCLASSXX ELFCLASS32
# define Elf_Ehdr Elf32_Ehdr
# define Elf_Phdr Elf32_Phdr
# define Elf_Shdr Elf32_Shdr
#elif defined(MULTIBOOT_LOAD_ELF64)
# define XX 64
# define E_MACHINE MULTIBOOT_ELF64_MACHINE
# define ELFCLASSXX ELFCLASS64
# define Elf_Ehdr Elf64_Ehdr
# define Elf_Phdr Elf64_Phdr
# define Elf_Shdr Elf64_Shdr
#else
#error "I'm confused"
#endif
@ -223,3 +225,4 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, void *buffer)
#undef ELFCLASSXX
#undef Elf_Ehdr
#undef Elf_Phdr
#undef Elf_Shdr