2008-09-01 Felix Zielcke * disk/scsi.c (DEBUG_CHANNEL): New macro. Update all `grub_dprintf' calls to use [DEBUG_CHANNEL]. * disk/ieee1275/ofdisk.c: Likewise. * disk/ata.c: Likewise. * disk/i386/pc/biosdisk.c: Likewise. * disk/raid.c: Likewise. * disk/efi/efidisk.c: Likewise. * disk/memdisk.c: Likewise. * kern/dl.c: Likewise. * kern/sparc64/ieee1275/openfw.c: Likewise. * kern/ieee1275/openfw.c: Likewise. * kern/elf.c: Likewise. * kern/fs.c: Likewise. * kern/partition.c: Likewise. * kern/disk.c: Likewise. * fs/reiserfs.c: Likewise. * normal/script.c: Likewise. * normal/lexer.c: Likewise. * commands/i386/pc/play.c: Likewise. * partmap/apple.c: Likewise. * partmap/pc.c: Likewise. * partmap/gpt.c: Likewise. * loader/powerpc/ieee1275/linux.c: Likewise. * loader/multiboot2.c: Likewise. * loader/multiboot_loader.c: Likewise. * loader/ieee1275/multiboot2.c: Likewise. * loader/i386/linux.c: Likewise. * loader/i386/pc/multiboot.c: Likewise. * loader/i386/efi/linux.c: Likewise. * term/i386/pc/at_keyboard.c: Likewise. Index: disk/scsi.c =================================================================== --- disk/scsi.c (Revision 1843) +++ disk/scsi.c (Arbeitskopie) @@ -28,6 +28,8 @@ #include +#define DEBUG_CHANNEL = "scsi"; + static grub_scsi_dev_t grub_scsi_dev_list; void @@ -259,17 +261,17 @@ grub_scsi_open (const char *name, grub_d return grub_errno; } - grub_dprintf ("scsi", "dev opened\n"); + grub_dprintf (DEBUG_CHANNEL, "dev opened\n"); err = grub_scsi_inquiry (scsi); if (err) { - grub_dprintf ("scsi", "inquiry failed\n"); + grub_dprintf (DEBUG_CHANNEL, "inquiry failed\n"); p->close (scsi); return grub_errno; } - grub_dprintf ("scsi", "inquiry: devtype=0x%02x removable=%d\n", + grub_dprintf (DEBUG_CHANNEL, "inquiry: devtype=0x%02x removable=%d\n", scsi->devtype, scsi->removable); /* Try to be conservative about the device types @@ -290,7 +292,7 @@ grub_scsi_open (const char *name, grub_d err = grub_scsi_read_capacity (scsi); if (err) { - grub_dprintf ("scsi", "READ CAPACITY failed\n"); + grub_dprintf (DEBUG_CHANNEL, "READ CAPACITY failed\n"); p->close (scsi); return grub_errno; } @@ -300,7 +302,7 @@ grub_scsi_open (const char *name, grub_d disk->total_sectors = ((scsi->size * scsi->blocksize) << GRUB_DISK_SECTOR_BITS); - grub_dprintf ("scsi", "capacity=%d, blksize=%d\n", + grub_dprintf (DEBUG_CHANNEL, "capacity=%d, blksize=%d\n", (int) disk->total_sectors, scsi->blocksize); return GRUB_ERR_NONE; Index: disk/ieee1275/ofdisk.c =================================================================== --- disk/ieee1275/ofdisk.c (Revision 1843) +++ disk/ieee1275/ofdisk.c (Arbeitskopie) @@ -1,7 +1,7 @@ /* ofdisk.c - Open Firmware disk access. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2004,2006,2007 Free Software Foundation, Inc. + * Copyright (C) 2004,2006,2007,2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,8 @@ #include #include +#define DEBUG_CHANNEL = "disk"; + static int grub_ofdisk_iterate (int (*hook) (const char *name)) { @@ -30,7 +32,7 @@ grub_ofdisk_iterate (int (*hook) (const int dev_iterate (struct grub_ieee1275_devalias *alias) { - grub_dprintf ("disk", "disk name = %s\n", alias->name); + grub_dprintf (DEBUG_CHANNEL, "disk name = %s\n", alias->name); if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_OFDISK_SDCARD_ONLY)) { @@ -39,20 +41,20 @@ grub_ofdisk_iterate (int (*hook) (const if (grub_ieee1275_finddevice (alias->path, &dev)) { - grub_dprintf ("disk", "finddevice (%s) failed\n", alias->path); + grub_dprintf (DEBUG_CHANNEL, "finddevice (%s) failed\n", alias->path); return 0; } if (grub_ieee1275_get_property (dev, "iconname", tmp, sizeof tmp, 0)) { - grub_dprintf ("disk", "get iconname failed\n"); + grub_dprintf (DEBUG_CHANNEL, "get iconname failed\n"); return 0; } if (grub_strcmp (tmp, "sdmmc")) { - grub_dprintf ("disk", "device is not an SD card\n"); + grub_dprintf (DEBUG_CHANNEL, "device is not an SD card\n"); return 0; } } @@ -89,7 +91,7 @@ grub_ofdisk_open (const char *name, grub if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0)) grub_strcat (devpath, ":0"); - grub_dprintf ("disk", "Opening `%s'.\n", devpath); + grub_dprintf (DEBUG_CHANNEL, "Opening `%s'.\n", devpath); grub_ieee1275_open (devpath, &dev_ihandle); if (! dev_ihandle) @@ -98,7 +100,7 @@ grub_ofdisk_open (const char *name, grub goto fail; } - grub_dprintf ("disk", "Opened `%s' as handle %p.\n", devpath, (void *) dev_ihandle); + grub_dprintf (DEBUG_CHANNEL, "Opened `%s' as handle %p.\n", devpath, (void *) dev_ihandle); if (grub_ieee1275_finddevice (devpath, &dev)) { @@ -144,7 +146,7 @@ grub_ofdisk_open (const char *name, grub static void grub_ofdisk_close (grub_disk_t disk) { - grub_dprintf ("disk", "Closing handle %p.\n", + grub_dprintf (DEBUG_CHANNEL, "Closing handle %p.\n", (void *) disk->data); grub_ieee1275_close ((grub_ieee1275_ihandle_t) disk->data); } @@ -156,7 +158,7 @@ grub_ofdisk_read (grub_disk_t disk, grub grub_ssize_t status, actual; unsigned long long pos; - grub_dprintf ("disk", + grub_dprintf (DEBUG_CHANNEL, "Reading handle %p: sector 0x%llx, size 0x%lx, buf %p.\n", (void *) disk->data, sector, (long) size, buf); Index: disk/ata.c =================================================================== --- disk/ata.c (Revision 1843) +++ disk/ata.c (Arbeitskopie) @@ -27,6 +27,8 @@ /* XXX: For now this only works on i386. */ #include +#define DEBUG_CHANNEL = "ata"; + typedef enum { GRUB_ATA_CHS, @@ -246,16 +248,16 @@ grub_ata_dumpinfo (struct grub_ata_devic /* The device information was read, dump it for debugging. */ grub_ata_strncpy (text, info + 20, 20); - grub_dprintf ("ata", "Serial: %s\n", text); + grub_dprintf (DEBUG_CHANNEL, "Serial: %s\n", text); grub_ata_strncpy (text, info + 46, 8); - grub_dprintf ("ata", "Firmware: %s\n", text); + grub_dprintf (DEBUG_CHANNEL, "Firmware: %s\n", text); grub_ata_strncpy (text, info + 54, 40); - grub_dprintf ("ata", "Model: %s\n", text); + grub_dprintf (DEBUG_CHANNEL, "Model: %s\n", text); if (! dev->atapi) { - grub_dprintf ("ata", "Addressing: %d\n", dev->addr); - grub_dprintf ("ata", "Sectors: %lld\n", dev->size); + grub_dprintf (DEBUG_CHANNEL, "Addressing: %d\n", dev->addr); + grub_dprintf (DEBUG_CHANNEL, "Sectors: %lld\n", dev->size); } } @@ -399,7 +401,7 @@ grub_ata_device_initialize (int port, in struct grub_ata_device *dev; struct grub_ata_device **devp; - grub_dprintf ("ata", "detecting device %d,%d (0x%x, 0x%x)\n", + grub_dprintf (DEBUG_CHANNEL, "detecting device %d,%d (0x%x, 0x%x)\n", port, device, addr, addr2); dev = grub_malloc (sizeof(*dev)); @@ -436,7 +438,7 @@ grub_ata_device_initialize (int port, in } grub_ata_wait (); - grub_dprintf ("ata", "Registers: %x %x %x %x\n", + grub_dprintf (DEBUG_CHANNEL, "Registers: %x %x %x %x\n", grub_ata_regget (dev, GRUB_ATA_REG_SECTORS), grub_ata_regget (dev, GRUB_ATA_REG_LBALOW), grub_ata_regget (dev, GRUB_ATA_REG_LBAMID), @@ -448,18 +450,18 @@ grub_ata_device_initialize (int port, in && grub_ata_regget (dev, GRUB_ATA_REG_LBAMID) == 0x14 && grub_ata_regget (dev, GRUB_ATA_REG_LBAHIGH) == 0xeb) { - grub_dprintf ("ata", "ATAPI signature detected\n"); + grub_dprintf (DEBUG_CHANNEL, "ATAPI signature detected\n"); } else if (grub_ata_regget (dev, GRUB_ATA_REG_SECTORS) == 0x01 && grub_ata_regget (dev, GRUB_ATA_REG_LBALOW) == 0x01 && grub_ata_regget (dev, GRUB_ATA_REG_LBAMID) == 0x00 && grub_ata_regget (dev, GRUB_ATA_REG_LBAHIGH) == 0x00) { - grub_dprintf ("ata", "ATA detected\n"); + grub_dprintf (DEBUG_CHANNEL, "ATA detected\n"); } else { - grub_dprintf ("ata", "incorrect signature\n"); + grub_dprintf (DEBUG_CHANNEL, "incorrect signature\n"); grub_free (dev); return 0; } @@ -534,7 +536,7 @@ grub_ata_pciinit (int bus, int device, i } } - grub_dprintf ("ata", + grub_dprintf (DEBUG_CHANNEL, "PCI dev (%d,%d,%d) compat=%d rega=0x%x regb=0x%x\n", bus, device, func, compat, rega, regb); @@ -905,7 +907,7 @@ grub_atapi_open (const char *name, struc } } - grub_dprintf ("ata", "opening ATAPI dev `%s'\n", name); + grub_dprintf (DEBUG_CHANNEL, "opening ATAPI dev `%s'\n", name); if (! devfnd) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "No such ATAPI device"); Index: disk/i386/pc/biosdisk.c =================================================================== --- disk/i386/pc/biosdisk.c (Revision 1843) +++ disk/i386/pc/biosdisk.c (Arbeitskopie) @@ -27,6 +27,8 @@ #include #include +#define DEBUG_CHANNEL = "disk"; + static int cd_drive = 0; static int @@ -72,7 +74,7 @@ grub_biosdisk_iterate (int (*hook) (cons if (grub_biosdisk_rw_standard (0x02, drive, 0, 0, 1, 1, GRUB_MEMORY_MACHINE_SCRATCH_SEG) != 0) { - grub_dprintf ("disk", "Read error when probing drive 0x%2x\n", drive); + grub_dprintf (DEBUG_CHANNEL, "Read error when probing drive 0x%2x\n", drive); break; } Index: disk/raid.c =================================================================== --- disk/raid.c (Revision 1843) +++ disk/raid.c (Arbeitskopie) @@ -24,6 +24,8 @@ #include #include +#define DEBUG_CHANNEL = "raid"; + /* Linked list of RAID arrays. */ static struct grub_raid_array *array_list; grub_raid5_recover_func_t grub_raid5_recover_func; @@ -130,7 +132,7 @@ grub_raid_open (const char *name, grub_d disk->id = array->number; disk->data = array; - grub_dprintf ("raid", "%s: total_devs=%d, disk_size=%lld\n", name, + grub_dprintf (DEBUG_CHANNEL, "%s: total_devs=%d, disk_size=%lld\n", name, array->total_devs, (unsigned long long) array->disk_size); switch (array->level) @@ -159,7 +161,7 @@ grub_raid_open (const char *name, grub_d break; } - grub_dprintf ("raid", "%s: level=%d, total_sectors=%lld\n", name, + grub_dprintf (DEBUG_CHANNEL, "%s: level=%d, total_sectors=%lld\n", name, array->level, (unsigned long long) disk->total_sectors); return 0; @@ -569,7 +571,7 @@ insert_array (grub_disk_t disk, struct g grub_sprintf (array->name, "md%d", array->number); - grub_dprintf ("raid", "Found array %s (%s)\n", array->name, + grub_dprintf (DEBUG_CHANNEL, "Found array %s (%s)\n", array->name, scanner_name); /* Add our new array to the list. */ @@ -596,7 +598,7 @@ grub_raid_scan_device (int head_only) struct grub_raid_array array; struct grub_raid *p; - grub_dprintf ("raid", "Scanning for RAID devices\n"); + grub_dprintf (DEBUG_CHANNEL, "Scanning for RAID devices\n"); disk = grub_disk_open (name); if (!disk) Index: disk/efi/efidisk.c =================================================================== --- disk/efi/efidisk.c (Revision 1843) +++ disk/efi/efidisk.c (Arbeitskopie) @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007 Free Software Foundation, Inc. + * Copyright (C) 2006,2007,2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,6 +27,8 @@ #include #include +#define DEBUG_CHANNEL = "efidisk"; + struct grub_efidisk_data { grub_efi_handle_t handle; @@ -441,7 +443,7 @@ grub_efidisk_iterate (int (*hook) (const for (d = fd_devices, count = 0; d; d = d->next, count++) { grub_sprintf (buf, "fd%d", count); - grub_dprintf ("efidisk", "iterating %s\n", buf); + grub_dprintf (DEBUG_CHANNEL, "iterating %s\n", buf); if (hook (buf)) return 1; } @@ -449,7 +451,7 @@ grub_efidisk_iterate (int (*hook) (const for (d = hd_devices, count = 0; d; d = d->next, count++) { grub_sprintf (buf, "hd%d", count); - grub_dprintf ("efidisk", "iterating %s\n", buf); + grub_dprintf (DEBUG_CHANNEL, "iterating %s\n", buf); if (hook (buf)) return 1; } @@ -457,7 +459,7 @@ grub_efidisk_iterate (int (*hook) (const for (d = cd_devices, count = 0; d; d = d->next, count++) { grub_sprintf (buf, "cd%d", count); - grub_dprintf ("efidisk", "iterating %s\n", buf); + grub_dprintf (DEBUG_CHANNEL, "iterating %s\n", buf); if (hook (buf)) return 1; } @@ -505,7 +507,7 @@ grub_efidisk_open (const char *name, str struct grub_efidisk_data *d = 0; grub_efi_block_io_media_t *m; - grub_dprintf ("efidisk", "opening %s\n", name); + grub_dprintf (DEBUG_CHANNEL, "opening %s\n", name); num = get_drive_number (name); if (num < 0) @@ -538,13 +540,13 @@ grub_efidisk_open (const char *name, str m = d->block_io->media; /* FIXME: Probably it is better to store the block size in the disk, and total sectors should be replaced with total blocks. */ - grub_dprintf ("efidisk", "m = %p, last block = %llx, block size = %x\n", + grub_dprintf (DEBUG_CHANNEL, "m = %p, last block = %llx, block size = %x\n", m, (unsigned long long) m->last_block, m->block_size); disk->total_sectors = (m->last_block * (m->block_size >> GRUB_DISK_SECTOR_BITS)); disk->data = d; - grub_dprintf ("efidisk", "opening %s succeeded\n", name); + grub_dprintf (DEBUG_CHANNEL, "opening %s succeeded\n", name); return GRUB_ERR_NONE; } @@ -553,7 +555,7 @@ static void grub_efidisk_close (struct grub_disk *disk __attribute__ ((unused))) { /* EFI disks do not allocate extra memory, so nothing to do here. */ - grub_dprintf ("efidisk", "closing %s\n", disk->name); + grub_dprintf (DEBUG_CHANNEL, "closing %s\n", disk->name); } static grub_err_t @@ -570,7 +572,7 @@ grub_efidisk_read (struct grub_disk *dis dio = d->disk_io; bio = d->block_io; - grub_dprintf ("efidisk", + grub_dprintf (DEBUG_CHANNEL, "reading 0x%lx sectors at the sector 0x%llx from %s\n", (unsigned long) size, (unsigned long long) sector, disk->name); @@ -598,7 +600,7 @@ grub_efidisk_write (struct grub_disk *di dio = d->disk_io; bio = d->block_io; - grub_dprintf ("efidisk", + grub_dprintf (DEBUG_CHANNEL, "writing 0x%lx sectors at the sector 0x%llx to %s\n", (unsigned long) size, (unsigned long long) sector, disk->name); Index: disk/memdisk.c =================================================================== --- disk/memdisk.c (Revision 1843) +++ disk/memdisk.c (Arbeitskopie) @@ -25,6 +25,8 @@ #include #include +#define DEBUG_CHANNEL = "memdisk"; + static char *memdisk_addr; static grub_off_t memdisk_size = 0; @@ -90,12 +92,12 @@ GRUB_MOD_INIT(memdisk) char *memdisk_orig_addr; memdisk_orig_addr = (char *) header + sizeof (struct grub_module_header); - grub_dprintf ("memdisk", "Found memdisk image at %p\n", memdisk_orig_addr); + grub_dprintf (DEBUG_CHANNEL, "Found memdisk image at %p\n", memdisk_orig_addr); memdisk_size = header->size - sizeof (struct grub_module_header); memdisk_addr = grub_malloc (memdisk_size); - grub_dprintf ("memdisk", "Copying memdisk image to dynamic memory\n"); + grub_dprintf (DEBUG_CHANNEL, "Copying memdisk image to dynamic memory\n"); grub_memmove (memdisk_addr, memdisk_orig_addr, memdisk_size); grub_disk_dev_register (&grub_memdisk_dev); Index: kern/dl.c =================================================================== --- kern/dl.c (Revision 1843) +++ kern/dl.c (Arbeitskopie) @@ -1,7 +1,7 @@ /* dl.c - loadable module support */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2004,2005,2007 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2004,2005,2007,2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,6 +29,8 @@ #include #include +#define DEBUG_CHANNEL = "modules"; + #if GRUB_CPU_SIZEOF_VOID_P == 4 typedef Elf32_Word Elf_Word; @@ -509,7 +511,7 @@ grub_dl_flush_cache (grub_dl_t mod) for (seg = mod->segment; seg; seg = seg->next) { if (seg->size) { - grub_dprintf ("modules", "flushing 0x%lx bytes at %p\n", + grub_dprintf (DEBUG_CHANNEL, "flushing 0x%lx bytes at %p\n", (unsigned long) seg->size, seg->addr); grub_arch_sync_caches (seg->addr, seg->size); } @@ -523,7 +525,7 @@ grub_dl_load_core (void *addr, grub_size Elf_Ehdr *e; grub_dl_t mod; - grub_dprintf ("modules", "module at %p, size 0x%lx\n", addr, + grub_dprintf (DEBUG_CHANNEL, "module at %p, size 0x%lx\n", addr, (unsigned long) size); e = addr; if (grub_dl_check_header (e, size)) @@ -553,7 +555,7 @@ grub_dl_load_core (void *addr, grub_size mod->init = 0; mod->fini = 0; - grub_dprintf ("modules", "relocating to %p\n", mod); + grub_dprintf (DEBUG_CHANNEL, "relocating to %p\n", mod); if (grub_dl_resolve_name (mod, e) || grub_dl_resolve_dependencies (mod, e) || grub_dl_load_segments (mod, e) @@ -567,8 +569,8 @@ grub_dl_load_core (void *addr, grub_size grub_dl_flush_cache (mod); - grub_dprintf ("modules", "module name: %s\n", mod->name); - grub_dprintf ("modules", "init function: %p\n", mod->init); + grub_dprintf (DEBUG_CHANNEL, "module name: %s\n", mod->name); + grub_dprintf (DEBUG_CHANNEL, "init function: %p\n", mod->init); grub_dl_call_init (mod); if (grub_dl_add (mod)) Index: kern/sparc64/ieee1275/openfw.c =================================================================== --- kern/sparc64/ieee1275/openfw.c (Revision 1843) +++ kern/sparc64/ieee1275/openfw.c (Arbeitskopie) @@ -23,6 +23,8 @@ #include /* Needed ? */ #include +#define DEBUG_CHANNEL = "devalias"; + enum grub_ieee1275_parse_type { GRUB_PARSE_FILENAME, @@ -105,7 +107,7 @@ grub_devalias_iterate (int (*hook) (stru grub_ssize_t pathlen, typelen; char *devpath, *devtype; - grub_dprintf ("devalias", "devalias name = %s\n", aliasname); + grub_dprintf (DEBUG_CHANNEL, "devalias name = %s\n", aliasname); /* The property `name' is a special case we should skip. */ if (!grub_strcmp (aliasname, "name")) @@ -119,14 +121,14 @@ grub_devalias_iterate (int (*hook) (stru if (grub_ieee1275_get_property (devalias, aliasname, devpath, pathlen, &actual)) { - grub_dprintf ("devalias", "get_property (%s) failed\n", aliasname); + grub_dprintf (DEBUG_CHANNEL, "get_property (%s) failed\n", aliasname); grub_free (devpath); continue; } if (grub_ieee1275_finddevice (devpath, &dev) || ((signed) dev) == -1) { - grub_dprintf ("devalias", "finddevice (%s) failed\n", devpath); + grub_dprintf (DEBUG_CHANNEL, "finddevice (%s) failed\n", devpath); grub_free (devpath); continue; } @@ -140,7 +142,7 @@ grub_devalias_iterate (int (*hook) (stru } if (grub_ieee1275_get_property (dev, "device_type", devtype, typelen, &actual)) { - grub_dprintf ("devalias", "get device type failed\n"); + grub_dprintf (DEBUG_CHANNEL, "get device type failed\n"); grub_free (devtype); grub_free (devpath); continue; Index: kern/ieee1275/openfw.c =================================================================== --- kern/ieee1275/openfw.c (Revision 1843) +++ kern/ieee1275/openfw.c (Arbeitskopie) @@ -25,6 +25,8 @@ #include #include +#define DEBUG_CHANNEL = "devalias"; + enum grub_ieee1275_parse_type { GRUB_PARSE_FILENAME, @@ -103,7 +105,7 @@ grub_devalias_iterate (int (*hook) (stru /* XXX: This should be large enough for any possible case. */ char devtype[64]; - grub_dprintf ("devalias", "devalias name = %s\n", aliasname); + grub_dprintf (DEBUG_CHANNEL, "devalias name = %s\n", aliasname); grub_ieee1275_get_property_length (aliases, aliasname, &pathlen); @@ -118,13 +120,13 @@ grub_devalias_iterate (int (*hook) (stru if (grub_ieee1275_get_property (aliases, aliasname, devpath, pathlen, &actual)) { - grub_dprintf ("devalias", "get_property (%s) failed\n", aliasname); + grub_dprintf (DEBUG_CHANNEL, "get_property (%s) failed\n", aliasname); goto nextprop; } if (grub_ieee1275_finddevice (devpath, &dev)) { - grub_dprintf ("devalias", "finddevice (%s) failed\n", devpath); + grub_dprintf (DEBUG_CHANNEL, "finddevice (%s) failed\n", devpath); goto nextprop; } Index: kern/elf.c =================================================================== --- kern/elf.c (Revision 1843) +++ kern/elf.c (Arbeitskopie) @@ -25,6 +25,8 @@ #include #include +#define DEBUG_CHANNEL = "elf"; + /* Check if EHDR is a valid ELF header. */ static grub_err_t grub_elf_check_header (grub_elf_t elf) @@ -123,7 +125,7 @@ grub_elf32_load_phdrs (grub_elf_t elf) phdrs_size = elf->ehdr.ehdr32.e_phnum * elf->ehdr.ehdr32.e_phentsize; - grub_dprintf ("elf", "Loading program headers at 0x%llx, size 0x%lx.\n", + grub_dprintf (DEBUG_CHANNEL, "Loading program headers at 0x%llx, size 0x%lx.\n", (unsigned long long) elf->ehdr.ehdr32.e_phoff, (unsigned long) phdrs_size); @@ -157,7 +159,7 @@ grub_elf32_phdr_iterate (grub_elf_t elf, for (i = 0; i < elf->ehdr.ehdr32.e_phnum; i++) { Elf32_Phdr *phdr = phdrs + i; - grub_dprintf ("elf", + grub_dprintf (DEBUG_CHANNEL, "Segment %u: type 0x%x paddr 0x%lx memsz 0x%lx " "filesz %lx\n", i, phdr->p_type, @@ -239,7 +241,7 @@ grub_elf32_load (grub_elf_t _elf, grub_e if (load_addr < load_base) load_base = load_addr; - grub_dprintf ("elf", "Loading segment at 0x%llx, size 0x%llx\n", + grub_dprintf (DEBUG_CHANNEL, "Loading segment at 0x%llx, size 0x%llx\n", (unsigned long long) load_addr, (unsigned long long) phdr->p_memsz); @@ -301,7 +303,7 @@ grub_elf64_load_phdrs (grub_elf_t elf) phdrs_size = elf->ehdr.ehdr64.e_phnum * elf->ehdr.ehdr64.e_phentsize; - grub_dprintf ("elf", "Loading program headers at 0x%llx, size 0x%lx.\n", + grub_dprintf (DEBUG_CHANNEL, "Loading program headers at 0x%llx, size 0x%lx.\n", (unsigned long long) elf->ehdr.ehdr64.e_phoff, (unsigned long) phdrs_size); @@ -335,7 +337,7 @@ grub_elf64_phdr_iterate (grub_elf_t elf, for (i = 0; i < elf->ehdr.ehdr64.e_phnum; i++) { Elf64_Phdr *phdr = phdrs + i; - grub_dprintf ("elf", + grub_dprintf (DEBUG_CHANNEL, "Segment %u: type 0x%x paddr 0x%lx memsz 0x%lx " "filesz %lx\n", i, phdr->p_type, @@ -418,7 +420,7 @@ grub_elf64_load (grub_elf_t _elf, grub_e if (load_addr < load_base) load_base = load_addr; - grub_dprintf ("elf", "Loading segment at 0x%llx, size 0x%llx\n", + grub_dprintf (DEBUG_CHANNEL, "Loading segment at 0x%llx, size 0x%llx\n", (unsigned long long) load_addr, (unsigned long long) phdr->p_memsz); Index: kern/fs.c =================================================================== --- kern/fs.c (Revision 1843) +++ kern/fs.c (Arbeitskopie) @@ -1,7 +1,7 @@ /* fs.c - filesystem manager */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2005,2007 Free Software Foundation, Inc. + * Copyright (C) 2002,2005,2007,2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,6 +27,8 @@ #include #include +#define DEBUG_CHANNEL = "fs"; + static grub_fs_t grub_fs_list; grub_fs_autoload_hook_t grub_fs_autoload_hook = 0; @@ -80,13 +82,13 @@ grub_fs_probe (grub_device_t device) for (p = grub_fs_list; p; p = p->next) { - grub_dprintf ("fs", "Detecting %s...\n", p->name); + grub_dprintf (DEBUG_CHANNEL, "Detecting %s...\n", p->name); (p->dir) (device, "/", dummy_func); if (grub_errno == GRUB_ERR_NONE) return p; grub_error_push (); - grub_dprintf ("fs", "%s detection failed.\n", p->name); + grub_dprintf (DEBUG_CHANNEL, "%s detection failed.\n", p->name); grub_error_pop (); if (grub_errno != GRUB_ERR_BAD_FS) Index: kern/partition.c =================================================================== --- kern/partition.c (Revision 1843) +++ kern/partition.c (Arbeitskopie) @@ -20,6 +20,8 @@ #include #include +#define DEBUG_CHANNEL = "partition"; + static grub_partition_map_t grub_partition_map_list; void @@ -103,18 +105,18 @@ grub_partition_iterate (struct grub_disk int part_map_iterate (const grub_partition_map_t p) { - grub_dprintf ("partition", "Detecting %s...\n", p->name); + grub_dprintf (DEBUG_CHANNEL, "Detecting %s...\n", p->name); p->iterate (disk, part_map_iterate_hook); if (grub_errno != GRUB_ERR_NONE) { /* Continue to next partition map type. */ - grub_dprintf ("partition", "%s detection failed.\n", p->name); + grub_dprintf (DEBUG_CHANNEL, "%s detection failed.\n", p->name); grub_errno = GRUB_ERR_NONE; return 0; } - grub_dprintf ("partition", "%s detection succeeded.\n", p->name); + grub_dprintf (DEBUG_CHANNEL, "%s detection succeeded.\n", p->name); partmap = p; return 1; } Index: kern/disk.c =================================================================== --- kern/disk.c (Revision 1843) +++ kern/disk.c (Arbeitskopie) @@ -27,6 +27,8 @@ #define GRUB_CACHE_TIMEOUT 2 +#define DEBUG_CHANNEL = "disk"; + /* The last time the disk was used. */ static grub_uint64_t grub_last_time = 0; @@ -217,7 +219,7 @@ grub_disk_open (const char *name) char *raw = (char *) name; grub_uint64_t current_time; - grub_dprintf ("disk", "Opening `%s'...\n", name); + grub_dprintf (DEBUG_CHANNEL, "Opening `%s'...\n", name); disk = (grub_disk_t) grub_malloc (sizeof (*disk)); if (! disk) @@ -296,7 +298,7 @@ grub_disk_open (const char *name) if (grub_errno != GRUB_ERR_NONE) { grub_error_push (); - grub_dprintf ("disk", "Opening `%s' failed.\n", name); + grub_dprintf (DEBUG_CHANNEL, "Opening `%s' failed.\n", name); grub_error_pop (); grub_disk_close (disk); @@ -309,7 +311,7 @@ grub_disk_open (const char *name) void grub_disk_close (grub_disk_t disk) { - grub_dprintf ("disk", "Closing `%s'.\n", disk->name); + grub_dprintf (DEBUG_CHANNEL, "Closing `%s'.\n", disk->name); if (disk->dev && disk->dev->close) (disk->dev->close) (disk); @@ -365,13 +367,13 @@ grub_disk_read (grub_disk_t disk, grub_d char *tmp_buf; unsigned real_offset; - grub_dprintf ("disk", "Reading `%s'...\n", disk->name); + grub_dprintf (DEBUG_CHANNEL, "Reading `%s'...\n", disk->name); /* First of all, check if the region is within the disk. */ if (grub_disk_adjust_range (disk, §or, &offset, size) != GRUB_ERR_NONE) { grub_error_push (); - grub_dprintf ("disk", "Read out of range: sector 0x%llx (%s).\n", + grub_dprintf (DEBUG_CHANNEL, "Read out of range: sector 0x%llx (%s).\n", (unsigned long long) sector, grub_errmsg); grub_error_pop (); return grub_errno; @@ -433,7 +435,7 @@ grub_disk_read (grub_disk_t disk, grub_d if ((disk->dev->read) (disk, sector, num, tmp_buf)) { grub_error_push (); - grub_dprintf ("disk", "%s read failed\n", disk->name); + grub_dprintf (DEBUG_CHANNEL, "%s read failed\n", disk->name); grub_error_pop (); goto finish; } @@ -504,7 +506,7 @@ grub_disk_write (grub_disk_t disk, grub_ { unsigned real_offset; - grub_dprintf ("disk", "Writing `%s'...\n", disk->name); + grub_dprintf (DEBUG_CHANNEL, "Writing `%s'...\n", disk->name); if (grub_disk_adjust_range (disk, §or, &offset, size) != GRUB_ERR_NONE) return -1; Index: fs/reiserfs.c =================================================================== --- fs/reiserfs.c (Revision 1843) +++ fs/reiserfs.c (Arbeitskopie) @@ -60,6 +60,8 @@ #define S_IFLNK 0xA000 +#define DEBUG_CHANNEL = "reiserfs"; + #ifndef GRUB_UTIL static grub_dl_t my_mod; #endif @@ -72,6 +74,7 @@ real_assert (int boolean, const char *fi grub_printf ("Assertion failed at %s:%d\n", file, line); } + enum grub_reiserfs_item_type { GRUB_REISERFS_STAT, @@ -735,7 +738,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_n goto fail; block_number = item->block_number; block_position = item->block_position; - grub_dprintf ("reiserfs", "Iterating directory...\n"); + grub_dprintf (DEBUG_CHANNEL, "Iterating directory...\n"); do { struct grub_reiserfs_directory_header *directory_headers; @@ -828,7 +831,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_n = grub_le_to_cpu16 (entry_item->header.version); entry_block_number = entry_item->block_number; #if 0 - grub_dprintf ("reiserfs", + grub_dprintf (DEBUG_CHANNEL, "version %04x block %08x (%08x) position %08x\n", entry_version, entry_block_number, ((grub_disk_addr_t) entry_block_number * block_size) / GRUB_DISK_SECTOR_SIZE, @@ -845,7 +848,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_n if (grub_errno) goto fail; #if 0 - grub_dprintf ("reiserfs", + grub_dprintf (DEBUG_CHANNEL, "%04x %04x %04x %04x %08x %08x | %08x %08x %08x %08x\n", grub_le_to_cpu16 (entry_v1_stat.mode), grub_le_to_cpu16 (entry_v1_stat.hardlink_count), @@ -857,7 +860,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_n grub_le_to_cpu32 (entry_v1_stat.ctime), grub_le_to_cpu32 (entry_v1_stat.rdev), grub_le_to_cpu32 (entry_v1_stat.first_direct_byte)); - grub_dprintf ("reiserfs", + grub_dprintf (DEBUG_CHANNEL, "%04x %04x %04x %04x %08x %08x | %08x %08x %08x %08x\n", entry_v1_stat.mode, entry_v1_stat.hardlink_count, @@ -887,7 +890,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_n if (grub_errno) goto fail; #if 0 - grub_dprintf ("reiserfs", + grub_dprintf (DEBUG_CHANNEL, "%04x %04x %08x %08x%08x | %08x %08x %08x %08x | %08x %08x %08x\n", grub_le_to_cpu16 (entry_v2_stat.mode), grub_le_to_cpu16 (entry_v2_stat.reserved), @@ -901,7 +904,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_n grub_le_to_cpu32 (entry_v2_stat.ctime), grub_le_to_cpu32 (entry_v2_stat.blocks), grub_le_to_cpu32 (entry_v2_stat.first_direct_byte)); - grub_dprintf ("reiserfs", + grub_dprintf (DEBUG_CHANNEL, "%04x %04x %08x %08x%08x | %08x %08x %08x %08x | %08x %08x %08x\n", entry_v2_stat.mode, entry_v2_stat.reserved, @@ -927,7 +930,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_n { /* Pseudo file ".." never has stat block. */ if (grub_strcmp (entry_name, "..")) - grub_dprintf ("reiserfs", + grub_dprintf (DEBUG_CHANNEL, "Warning : %s has no stat block !\n", entry_name); grub_free (entry_item); @@ -936,7 +939,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_n } if (hook (entry_name, entry_type, entry_item)) { - grub_dprintf ("reiserfs", "Found : %s, type=%d\n", + grub_dprintf (DEBUG_CHANNEL, "Found : %s, type=%d\n", entry_name, entry_type); ret = 1; goto found; @@ -1050,7 +1053,7 @@ grub_reiserfs_open (struct grub_file *fi goto fail; file->size = (grub_off_t) grub_le_to_cpu64 (entry_v2_stat.size); } - grub_dprintf ("reiserfs", "file size : %d (%08x%08x)\n", + grub_dprintf (DEBUG_CHANNEL, "file size : %d (%08x%08x)\n", (unsigned int) file->size, (unsigned int) (file->size >> 32), (unsigned int) file->size); file->offset = 0; @@ -1093,7 +1096,7 @@ grub_reiserfs_read (grub_file_t file, ch initial_position = file->offset; current_position = 0; final_position = MIN (len + initial_position, file->size); - grub_dprintf ("reiserfs", + grub_dprintf (DEBUG_CHANNEL, "Reading from %lld to %lld (%lld instead of requested %ld)\n", (unsigned long long) initial_position, (unsigned long long) final_position, @@ -1118,7 +1121,7 @@ grub_reiserfs_read (grub_file_t file, ch offset = MAX ((signed) (initial_position - current_position), 0); length = (MIN (item_size, final_position - current_position) - offset); - grub_dprintf ("reiserfs", + grub_dprintf (DEBUG_CHANNEL, "Reading direct block %u from %u to %u...\n", (unsigned) block, (unsigned) offset, (unsigned) (offset + length)); @@ -1163,12 +1166,12 @@ grub_reiserfs_read (grub_file_t file, ch 0); length = (MIN (block_size, final_position - current_position) - offset); - grub_dprintf ("reiserfs", + grub_dprintf (DEBUG_CHANNEL, "Reading indirect block %u from %u to %u...\n", (unsigned) block, (unsigned) offset, (unsigned) (offset + length)); #if 0 - grub_dprintf ("reiserfs", + grub_dprintf (DEBUG_CHANNEL, "\nib=%04d/%04d, ip=%d, cp=%d, fp=%d, off=%d, l=%d, tl=%d\n", indirect_block + 1, indirect_block_count, initial_position, current_position, @@ -1193,7 +1196,7 @@ grub_reiserfs_read (grub_file_t file, ch current_key_offset = current_position + 1; } - grub_dprintf ("reiserfs", + grub_dprintf (DEBUG_CHANNEL, "Have successfully read %lld bytes (%ld requested)\n", (unsigned long long) (current_position - initial_position), (unsigned long) len); Index: normal/script.c =================================================================== --- normal/script.c (Revision 1843) +++ normal/script.c (Arbeitskopie) @@ -22,6 +22,8 @@ #include #include +#define DEBUG_CHANNEL = "scripting"; + /* It is not possible to deallocate the memory when a syntax error was found. Because of that it is required to keep track of all memory allocations. The memory is freed in case of an error, or @@ -47,7 +49,7 @@ grub_script_malloc (struct grub_parser_p mem = (struct grub_script_mem *) grub_malloc (size + sizeof (*mem) - sizeof (char)); - grub_dprintf ("scripting", "malloc %p\n", mem); + grub_dprintf (DEBUG_CHANNEL, "malloc %p\n", mem); mem->next = state->memused; state->memused = mem; return (void *) &mem->mem; @@ -62,7 +64,7 @@ grub_script_mem_free (struct grub_script while (mem) { memfree = mem->next; - grub_dprintf ("scripting", "free %p\n", mem); + grub_dprintf (DEBUG_CHANNEL, "free %p\n", mem); grub_free (mem); mem = memfree; } @@ -134,7 +136,7 @@ grub_script_add_arglist (struct grub_par struct grub_script_arglist *link; struct grub_script_arglist *ll; - grub_dprintf ("scripting", "arglist\n"); + grub_dprintf (DEBUG_CHANNEL, "arglist\n"); link = (struct grub_script_arglist *) grub_script_malloc (state, sizeof (*link)); link->next = 0; @@ -165,7 +167,7 @@ grub_script_create_cmdline (struct grub_ { struct grub_script_cmdline *cmd; - grub_dprintf ("scripting", "cmdline\n"); + grub_dprintf (DEBUG_CHANNEL, "cmdline\n"); cmd = grub_script_malloc (state, sizeof (*cmd)); cmd->cmd.exec = grub_script_execute_cmdline; @@ -188,7 +190,7 @@ grub_script_create_cmdif (struct grub_pa { struct grub_script_cmdif *cmd; - grub_dprintf ("scripting", "cmdif\n"); + grub_dprintf (DEBUG_CHANNEL, "cmdif\n"); cmd = grub_script_malloc (state, sizeof (*cmd)); cmd->cmd.exec = grub_script_execute_cmdif; @@ -246,7 +248,7 @@ grub_script_add_cmd (struct grub_parser_ struct grub_script_cmdblock *cmdblock, struct grub_script_cmd *cmd) { - grub_dprintf ("scripting", "cmdblock\n"); + grub_dprintf (DEBUG_CHANNEL, "cmdblock\n"); if (! cmd) return (struct grub_script_cmd *) cmdblock; Index: normal/lexer.c =================================================================== --- normal/lexer.c (Revision 1843) +++ normal/lexer.c (Arbeitskopie) @@ -1,7 +1,7 @@ /* lexer.c - The scripting lexer. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2005,2006,2007 Free Software Foundation, Inc. + * Copyright (C) 2005,2006,2007,2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,6 +24,8 @@ #include "grub_script.tab.h" +#define DEBUG_CHANNEL = "scripting"; + static int check_varstate (grub_parser_state_t state) { @@ -181,7 +183,7 @@ grub_script_yylex2 (union YYSTYPE *yylva if (! state->script) return 0; } - grub_dprintf ("scripting", "token=`\\n'\n"); + grub_dprintf (DEBUG_CHANNEL, "token=`\\n'\n"); recordchar (state, '\n'); if (state->state != GRUB_PARSER_STATE_ESC) return '\n'; @@ -191,7 +193,7 @@ grub_script_yylex2 (union YYSTYPE *yylva grub_free (state->newscript); state->newscript = 0; state->done = 1; - grub_dprintf ("scripting", "token=`\\n'\n"); + grub_dprintf (DEBUG_CHANNEL, "token=`\\n'\n"); return '\n'; } } @@ -215,13 +217,13 @@ grub_script_yylex2 (union YYSTYPE *yylva if (! (state->state == GRUB_PARSER_STATE_TEXT && *state->script == ' ')) { - grub_dprintf ("scripting", "token=` '\n"); + grub_dprintf (DEBUG_CHANNEL, "token=` '\n"); return ' '; } state->state = newstate; nextchar (state); } - grub_dprintf ("scripting", "token=` '\n"); + grub_dprintf (DEBUG_CHANNEL, "token=` '\n"); return ' '; case '{': case '}': @@ -229,7 +231,7 @@ grub_script_yylex2 (union YYSTYPE *yylva case '\n': { char c; - grub_dprintf ("scripting", "token=`%c'\n", *state->script); + grub_dprintf (DEBUG_CHANNEL, "token=`%c'\n", *state->script); c = *state->script;; nextchar (state); return c; @@ -284,7 +286,7 @@ grub_script_yylex2 (union YYSTYPE *yylva /* A string of text was read in. */ *bp = '\0'; - grub_dprintf ("scripting", "token=`%s'\n", buffer); + grub_dprintf (DEBUG_CHANNEL, "token=`%s'\n", buffer); yylval->string = buffer; /* Detect some special tokens. */ @@ -343,7 +345,7 @@ grub_script_yylex2 (union YYSTYPE *yylva *bp = '\0'; state->state = newstate; yylval->string = buffer; - grub_dprintf ("scripting", "vartoken=`%s'\n", buffer); + grub_dprintf (DEBUG_CHANNEL, "vartoken=`%s'\n", buffer); return GRUB_PARSER_TOKEN_VAR; } Index: commands/i386/pc/play.c =================================================================== --- commands/i386/pc/play.c (Revision 1843) +++ commands/i386/pc/play.c (Arbeitskopie) @@ -1,7 +1,7 @@ /* play.c - command to play a tune */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2005,2007 Free Software Foundation, Inc. + * Copyright (C) 2005,2007,2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -110,6 +110,8 @@ struct note short duration; }; +#define DEBUG_CHANNEL = "play"; + static void beep_off (void) { @@ -166,14 +168,14 @@ grub_cmd_play (struct grub_arg_list *sta "file doesn't even contains a full tempo record"); } - grub_dprintf ("play","tempo = %d\n", tempo); + grub_dprintf (DEBUG_CHANNEL,"tempo = %d\n", tempo); while (grub_file_read (file, (void *) &buf, sizeof (struct note)) == sizeof (struct note) && buf.pitch != T_FINE && grub_checkkey () < 0) { - grub_dprintf ("play", "pitch = %d, duration = %d\n", buf.pitch, + grub_dprintf (DEBUG_CHANNEL, "pitch = %d, duration = %d\n", buf.pitch, buf.duration); switch (buf.pitch) Index: partmap/apple.c =================================================================== --- partmap/apple.c (Revision 1843) +++ partmap/apple.c (Arbeitskopie) @@ -25,6 +25,8 @@ #define GRUB_APPLE_HEADER_MAGIC 0x4552 #define GRUB_APPLE_PART_MAGIC 0x504D +#define DEBUG_CHANNEL = "partition"; + struct grub_apple_header { /* The magic number to identify the partition map, it should have @@ -123,7 +125,7 @@ apple_partition_map_iterate (grub_disk_t if (grub_be_to_cpu16 (aheader.magic) != GRUB_APPLE_HEADER_MAGIC) { - grub_dprintf ("partition", + grub_dprintf (DEBUG_CHANNEL, "bad magic (found 0x%x; wanted 0x%x\n", grub_be_to_cpu16 (aheader.magic), GRUB_APPLE_HEADER_MAGIC); @@ -139,7 +141,7 @@ apple_partition_map_iterate (grub_disk_t if (grub_be_to_cpu16 (apart.magic) != GRUB_APPLE_PART_MAGIC) { - grub_dprintf ("partition", + grub_dprintf (DEBUG_CHANNEL, "partition %d: bad magic (found 0x%x; wanted 0x%x\n", partno, grub_be_to_cpu16 (apart.magic), GRUB_APPLE_PART_MAGIC); @@ -151,7 +153,7 @@ apple_partition_map_iterate (grub_disk_t part.offset = pos; part.index = partno; - grub_dprintf ("partition", + grub_dprintf (DEBUG_CHANNEL, "partition %d: name %s, type %s, start 0x%x, len 0x%x\n", partno, apart.partname, apart.parttype, grub_be_to_cpu32 (apart.first_phys_block), Index: partmap/pc.c =================================================================== --- partmap/pc.c (Revision 1843) +++ partmap/pc.c (Arbeitskopie) @@ -1,7 +1,7 @@ /* pc.c - Read PC style partition tables. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2004,2005,2006,2007 Free Software Foundation, Inc. + * Copyright (C) 2002,2004,2005,2006,2007,2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,6 +29,8 @@ static struct grub_partition_map grub_pc #ifndef GRUB_UTIL static grub_dl_t my_mod; #endif + +#define DEBUG_CHANNEL = "partition"; /* Parse the partition representation in STR and return a partition. */ @@ -136,7 +138,7 @@ pc_partition_map_iterate (grub_disk_t di pcdata.dos_type = e->type; pcdata.bsd_type = -1; - grub_dprintf ("partition", + grub_dprintf (DEBUG_CHANNEL, "partition %d: flag 0x%x, type 0x%x, start 0x%llx, len 0x%llx\n", p.index, e->flag, pcdata.dos_type, (unsigned long long) p.start, Index: partmap/gpt.c =================================================================== --- partmap/gpt.c (Revision 1843) +++ partmap/gpt.c (Arbeitskopie) @@ -25,6 +25,8 @@ #include #include +#define DEBUG_CHANNEL = "gpt"; + static grub_uint8_t grub_gpt_magic[8] = { 0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54 @@ -77,7 +79,7 @@ gpt_partition_map_iterate (grub_disk_t d if (grub_memcmp (gpt.magic, grub_gpt_magic, sizeof (grub_gpt_magic))) return grub_error (GRUB_ERR_BAD_PART_TABLE, "no valid GPT header"); - grub_dprintf ("gpt", "Read a valid GPT header\n"); + grub_dprintf (DEBUG_CHANNEL, "Read a valid GPT header\n"); entries = grub_le_to_cpu64 (gpt.partitions); for (i = 0; i < grub_le_to_cpu32 (gpt.maxpart); i++) @@ -98,7 +100,7 @@ gpt_partition_map_iterate (grub_disk_t d part.partmap = &grub_gpt_partition_map; part.data = &entry; - grub_dprintf ("gpt", "GPT entry %d: start=%lld, length=%lld\n", i, + grub_dprintf (DEBUG_CHANNEL, "GPT entry %d: start=%lld, length=%lld\n", i, (unsigned long long) part.start, (unsigned long long) part.len); Index: loader/powerpc/ieee1275/linux.c =================================================================== --- loader/powerpc/ieee1275/linux.c (Revision 1843) +++ loader/powerpc/ieee1275/linux.c (Arbeitskopie) @@ -1,7 +1,7 @@ /* linux.c - boot Linux */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc. + * Copyright (C) 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,6 +30,8 @@ #define ELF32_LOADMASK (0xc0000000UL) #define ELF64_LOADMASK (0xc000000000000000ULL) +#define DEBUG_CHANNEL = "loader"; + static grub_dl_t my_mod; static int loaded; @@ -55,11 +57,11 @@ grub_linux_boot (void) grub_ieee1275_set_property (grub_ieee1275_chosen, "bootargs", linux_args, grub_strlen (linux_args) + 1, &actual); - grub_dprintf ("loader", "Entry point: 0x%x\n", linux_addr); - grub_dprintf ("loader", "Initrd at: 0x%x, size 0x%x\n", initrd_addr, + grub_dprintf (DEBUG_CHANNEL, "Entry point: 0x%x\n", linux_addr); + grub_dprintf (DEBUG_CHANNEL, "Initrd at: 0x%x, size 0x%x\n", initrd_addr, initrd_size); - grub_dprintf ("loader", "Boot arguments: %s\n", linux_args); - grub_dprintf ("loader", "Jumping to Linux...\n"); + grub_dprintf (DEBUG_CHANNEL, "Boot arguments: %s\n", linux_args); + grub_dprintf (DEBUG_CHANNEL, "Jumping to Linux...\n"); /* Boot the kernel. */ linuxmain = (kernel_entry_t) linux_addr; @@ -121,7 +123,7 @@ grub_linux_load32 (grub_elf_t elf) * until we find an open area. */ for (linux_addr = entry; linux_addr < entry + 200 * 0x100000; linux_addr += 0x100000) { - grub_dprintf ("loader", "Attempting to claim at 0x%x, size 0x%x.\n", + grub_dprintf (DEBUG_CHANNEL, "Attempting to claim at 0x%x, size 0x%x.\n", linux_addr, linux_size); found_addr = grub_claimmap (linux_addr, linux_size); if (found_addr != -1) @@ -164,7 +166,7 @@ grub_linux_load64 (grub_elf_t elf) * until we find an open area. */ for (linux_addr = entry; linux_addr < entry + 200 * 0x100000; linux_addr += 0x100000) { - grub_dprintf ("loader", "Attempting to claim at 0x%x, size 0x%x.\n", + grub_dprintf (DEBUG_CHANNEL, "Attempting to claim at 0x%x, size 0x%x.\n", linux_addr, linux_size); found_addr = grub_claimmap (linux_addr, linux_size); if (found_addr != -1) @@ -295,7 +297,7 @@ grub_rescue_cmd_initrd (int argc, char * the same way that grub_rescue_cmd_linux does. */ for (addr = first_addr; addr < first_addr + 200 * 0x100000; addr += 0x100000) { - grub_dprintf ("loader", "Attempting to claim at 0x%x, size 0x%x.\n", + grub_dprintf (DEBUG_CHANNEL, "Attempting to claim at 0x%x, size 0x%x.\n", addr, size); found_addr = grub_claimmap (addr, size); if (found_addr != -1) @@ -308,7 +310,7 @@ grub_rescue_cmd_initrd (int argc, char * goto fail; } - grub_dprintf ("loader", "Loading initrd at 0x%x, size 0x%x\n", addr, size); + grub_dprintf (DEBUG_CHANNEL, "Loading initrd at 0x%x, size 0x%x\n", addr, size); if (grub_file_read (file, (void *) addr, size) != size) { Index: loader/multiboot2.c =================================================================== --- loader/multiboot2.c (Revision 1843) +++ loader/multiboot2.c (Arbeitskopie) @@ -30,6 +30,8 @@ #include #include +#define DEBUG_CHANNEL = "loader"; + static grub_addr_t entry; extern grub_dl_t my_mod; @@ -41,7 +43,7 @@ static int grub_mb2_tags_count; static void grub_mb2_tags_free (void) { - grub_dprintf ("loader", "Freeing all tags...\n"); + grub_dprintf (DEBUG_CHANNEL, "Freeing all tags...\n"); grub_free (grub_mb2_tags); grub_mb2_tags = 0; grub_mb2_tags_pos = 0; @@ -56,7 +58,7 @@ grub_mb2_tag_alloc (grub_addr_t *addr, i grub_size_t used; grub_size_t needed; - grub_dprintf ("loader", "Allocating tag: key 0x%x, size 0x%lx.\n", + grub_dprintf (DEBUG_CHANNEL, "Allocating tag: key 0x%x, size 0x%lx.\n", key, (unsigned long) len); used = grub_mb2_tags_pos - grub_mb2_tags; @@ -70,7 +72,7 @@ grub_mb2_tag_alloc (grub_addr_t *addr, i grub_size_t newsize = needed * 2; char *newarea; - grub_dprintf ("loader", "Reallocating tag buffer (new size 0x%lx).\n", + grub_dprintf (DEBUG_CHANNEL, "Reallocating tag buffer (new size 0x%lx).\n", (unsigned long) newsize); newarea = grub_malloc (newsize); @@ -95,7 +97,7 @@ grub_mb2_tag_alloc (grub_addr_t *addr, i grub_mb2_tags_count++; - grub_dprintf ("loader", "Allocated tag %u at %p.\n", grub_mb2_tags_count, tag); + grub_dprintf (DEBUG_CHANNEL, "Allocated tag %u at %p.\n", grub_mb2_tags_count, tag); return 0; } @@ -186,7 +188,7 @@ grub_mb2_boot (void) { grub_mb2_tags_finish (); - grub_dprintf ("loader", "Tags at %p\n", grub_mb2_tags); + grub_dprintf (DEBUG_CHANNEL, "Tags at %p\n", grub_mb2_tags); grub_mb2_arch_boot (entry, grub_mb2_tags); /* Not reached. */ @@ -294,7 +296,7 @@ grub_mb2_load_elf (grub_elf_t elf, int a if (err) goto fail; - grub_dprintf ("loader", "Entry point is 0x%lx.\n", (unsigned long) entry); + grub_dprintf (DEBUG_CHANNEL, "Entry point is 0x%lx.\n", (unsigned long) entry); grub_mb2_tag_module_create (kern_base, kern_size, "kernel", MULTIBOOT2_TAG_MODULE, argc, argv); @@ -354,25 +356,25 @@ grub_multiboot2 (int argc, char *argv[]) } if (! header_found) - grub_dprintf ("loader", "No multiboot 2 header found.\n"); + grub_dprintf (DEBUG_CHANNEL, "No multiboot 2 header found.\n"); /* Create the basic tags. */ - grub_dprintf ("loader", "Creating multiboot 2 tags\n"); + grub_dprintf (DEBUG_CHANNEL, "Creating multiboot 2 tags\n"); grub_mb2_tags_create (); /* Load the kernel and create its tag. */ elf = grub_elf_file (file); if (elf) { - grub_dprintf ("loader", "Loading ELF multiboot 2 file.\n"); + grub_dprintf (DEBUG_CHANNEL, "Loading ELF multiboot 2 file.\n"); err = grub_mb2_load_elf (elf, argc-1, &argv[1]); grub_elf_close (elf); } else { grub_errno = 0; - grub_dprintf ("loader", "Loading non-ELF multiboot 2 file.\n"); + grub_dprintf (DEBUG_CHANNEL, "Loading non-ELF multiboot 2 file.\n"); if (header) err = grub_mb2_load_other (file, header); @@ -433,7 +435,7 @@ grub_module2 (int argc, char *argv[]) if (err) goto out; - grub_dprintf ("loader", "Loading module at 0x%x - 0x%x\n", modaddr, + grub_dprintf (DEBUG_CHANNEL, "Loading module at 0x%x - 0x%x\n", modaddr, modaddr + modsize); if (grub_file_read (file, (char *) modaddr, modsize) != modsize) { Index: loader/multiboot_loader.c =================================================================== --- loader/multiboot_loader.c (Revision 1843) +++ loader/multiboot_loader.c (Arbeitskopie) @@ -31,6 +31,8 @@ #include #include +#define DEBUG_CHANNEL = "multiboot_loader"; + grub_dl_t my_mod; /* This tracks which version of multiboot to use when using @@ -101,7 +103,7 @@ grub_rescue_cmd_multiboot_loader (int ar /* The behavior is that if you don't find a multiboot 1 header use multiboot 2 loader (as you do not have to have a header to use multiboot 2 */ - grub_dprintf ("multiboot_loader", "No multiboot 1 header found. \n \ + grub_dprintf (DEBUG_CHANNEL, "No multiboot 1 header found. \n \ Using multiboot 2 loader\n"); header_multi_ver_found = 0; } @@ -117,7 +119,7 @@ grub_rescue_cmd_multiboot_loader (int ar #if defined(GRUB_MACHINE_PCBIOS) || defined(GRUB_MACHINE_LINUXBIOS) if (header_multi_ver_found == 1) { - grub_dprintf ("multiboot_loader", + grub_dprintf (DEBUG_CHANNEL, "Launching multiboot 1 grub_multiboot() function\n"); grub_multiboot (argc, argv); module_version_status = 1; @@ -125,7 +127,7 @@ grub_rescue_cmd_multiboot_loader (int ar #endif if (header_multi_ver_found == 0 || header_multi_ver_found == 2) { - grub_dprintf ("multiboot_loader", + grub_dprintf (DEBUG_CHANNEL, "Launching multiboot 2 grub_multiboot2() function\n"); grub_multiboot2 (argc, argv); module_version_status = 2; @@ -147,14 +149,14 @@ grub_rescue_cmd_module_loader (int argc, #if defined(GRUB_MACHINE_PCBIOS) || defined(GRUB_MACHINE_LINUXBIOS) if (module_version_status == 1) { - grub_dprintf("multiboot_loader", + grub_dprintf(DEBUG_CHANNEL, "Launching multiboot 1 grub_module() function\n"); grub_module (argc, argv); } #endif if (module_version_status == 2) { - grub_dprintf("multiboot_loader", + grub_dprintf(DEBUG_CHANNEL, "Launching multiboot 2 grub_module2() function\n"); grub_module2 (argc, argv); } Index: loader/ieee1275/multiboot2.c =================================================================== --- loader/ieee1275/multiboot2.c (Revision 1843) +++ loader/ieee1275/multiboot2.c (Arbeitskopie) @@ -1,7 +1,7 @@ /* multiboot.c - boot a multiboot 2 OS image. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2007 Free Software Foundation, Inc. + * Copyright (C) 2007,2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,6 +28,8 @@ #include #include +#define DEBUG_CHANNEL = "loader"; + typedef void (*kernel_entry_t) (unsigned long, void *, int (void *), unsigned long, unsigned long); @@ -42,7 +44,7 @@ grub_mb2_arch_elf32_hook (Elf32_Phdr *ph return grub_error(GRUB_ERR_OUT_OF_MEMORY, "Couldn't claim %x - %x", phdr->p_paddr, phdr->p_paddr + phdr->p_memsz); - grub_dprintf ("loader", "Loading segment at 0x%x - 0x%x\n", phdr->p_paddr, + grub_dprintf (DEBUG_CHANNEL, "Loading segment at 0x%x - 0x%x\n", phdr->p_paddr, phdr->p_paddr + phdr->p_memsz); return GRUB_ERR_NONE; @@ -59,7 +61,7 @@ grub_mb2_arch_elf64_hook (Elf64_Phdr *ph return grub_error(GRUB_ERR_OUT_OF_MEMORY, "Couldn't claim 0x%lx - 0x%lx", phdr->p_paddr, phdr->p_paddr + phdr->p_memsz); - grub_dprintf ("loader", "Loading segment at 0x%lx - 0x%lx\n", + grub_dprintf (DEBUG_CHANNEL, "Loading segment at 0x%lx - 0x%lx\n", (unsigned long) phdr->p_paddr, (unsigned long) (phdr->p_paddr + phdr->p_memsz)); Index: loader/i386/linux.c =================================================================== --- loader/i386/linux.c (Revision 1843) +++ loader/i386/linux.c (Arbeitskopie) @@ -35,6 +35,8 @@ static grub_dl_t my_mod; +#define DEBUG_CHANNEL = "linux"; + static grub_size_t linux_mem_size; static int loaded; static void *real_mode_mem; @@ -130,7 +132,7 @@ allocate_pages (grub_size_t prot_size) prot_size = page_align (prot_size); mmap_size = find_mmap_size (); - grub_dprintf ("linux", "real_size = %x, prot_size = %x, mmap_size = %x\n", + grub_dprintf (DEBUG_CHANNEL, "real_size = %x, prot_size = %x, mmap_size = %x\n", (unsigned) real_size, (unsigned) prot_size, (unsigned) mmap_size); /* Calculate the number of pages; Combine the real mode code with @@ -160,7 +162,7 @@ allocate_pages (grub_size_t prot_size) goto fail; } - grub_dprintf ("linux", "real_mode_mem = %lx, real_mode_pages = %x, " + grub_dprintf (DEBUG_CHANNEL, "real_mode_mem = %lx, real_mode_pages = %x, " "prot_mode_mem = %lx, prot_mode_pages = %x\n", (unsigned long) real_mode_mem, (unsigned) real_mode_pages, (unsigned long) prot_mode_mem, (unsigned) prot_mode_pages); @@ -210,11 +212,11 @@ grub_linux32_boot (void) params = real_mode_mem; - grub_dprintf ("linux", "code32_start = %x, idt_desc = %lx, gdt_desc = %lx\n", + grub_dprintf (DEBUG_CHANNEL, "code32_start = %x, idt_desc = %lx, gdt_desc = %lx\n", (unsigned) params->code32_start, (unsigned long) &(idt_desc.limit), (unsigned long) &(gdt_desc.limit)); - grub_dprintf ("linux", "idt = %x:%lx, gdt = %x:%lx\n", + grub_dprintf (DEBUG_CHANNEL, "idt = %x:%lx, gdt = %x:%lx\n", (unsigned) idt_desc.limit, (unsigned long) idt_desc.base, (unsigned) gdt_desc.limit, (unsigned long) gdt_desc.base); Index: loader/i386/pc/multiboot.c =================================================================== --- loader/i386/pc/multiboot.c (Revision 1843) +++ loader/i386/pc/multiboot.c (Arbeitskopie) @@ -43,6 +43,8 @@ #include #include +#define DEBUG_CHANNEL = "multiboot_loader"; + extern grub_dl_t my_mod; static struct grub_multiboot_info *mbi; static grub_addr_t entry; @@ -186,7 +188,7 @@ grub_multiboot_load_elf32 (grub_file_t f { char *load_this_module_at = (char *) (grub_multiboot_payload_orig + (phdr(i)->p_paddr - phdr(0)->p_paddr)); - grub_dprintf ("multiboot_loader", "segment %d: paddr=%p, memsz=0x%x\n", + grub_dprintf (DEBUG_CHANNEL, "segment %d: paddr=%p, memsz=0x%x\n", i, (void *) phdr(i)->p_paddr, phdr(i)->p_memsz); if (grub_file_seek (file, (grub_off_t) phdr(i)->p_offset) @@ -480,7 +482,7 @@ grub_multiboot (int argc, char *argv[]) entry = (grub_addr_t) grub_multiboot_payload_orig + grub_multiboot_payload_size; } - grub_dprintf ("multiboot_loader", "dest=%p, size=0x%x, entry_offset=0x%x\n", + grub_dprintf (DEBUG_CHANNEL, "dest=%p, size=0x%x, entry_offset=0x%x\n", (void *) grub_multiboot_payload_dest, grub_multiboot_payload_size, grub_multiboot_payload_entry_offset); Index: loader/i386/efi/linux.c =================================================================== --- loader/i386/efi/linux.c (Revision 1843) +++ loader/i386/efi/linux.c (Arbeitskopie) @@ -41,6 +41,8 @@ static grub_dl_t my_mod; +#define DEBUG_CHANNEL = "linux"; + static grub_size_t linux_mem_size; static int loaded; static void *real_mode_mem; @@ -170,7 +172,7 @@ allocate_pages (grub_size_t prot_size) prot_size = page_align (prot_size); mmap_size = find_mmap_size (); - grub_dprintf ("linux", "real_size = %x, prot_size = %x, mmap_size = %x\n", + grub_dprintf (DEBUG_CHANNEL, "real_size = %x, prot_size = %x, mmap_size = %x\n", (unsigned) real_size, (unsigned) prot_size, (unsigned) mmap_size); /* Calculate the number of pages; Combine the real mode code with @@ -212,14 +214,14 @@ allocate_pages (grub_size_t prot_size) if (physical_end > 0x90000) physical_end = 0x90000; - grub_dprintf ("linux", "physical_start = %x, physical_end = %x\n", + grub_dprintf (DEBUG_CHANNEL, "physical_start = %x, physical_end = %x\n", (unsigned) desc->physical_start, (unsigned) physical_end); addr = physical_end - real_size - mmap_size; if (addr < 0x10000) continue; - grub_dprintf ("linux", "trying to allocate %u pages at %lx\n", + grub_dprintf (DEBUG_CHANNEL, "trying to allocate %u pages at %lx\n", (unsigned) real_mode_pages, (unsigned long) addr); real_mode_mem = grub_efi_allocate_pages (addr, real_mode_pages); if (! real_mode_mem) @@ -248,7 +250,7 @@ allocate_pages (grub_size_t prot_size) goto fail; } - grub_dprintf ("linux", "real_mode_mem = %lx, real_mode_pages = %x, " + grub_dprintf (DEBUG_CHANNEL, "real_mode_mem = %lx, real_mode_pages = %x, " "prot_mode_mem = %lx, prot_mode_pages = %x\n", (unsigned long) real_mode_mem, (unsigned) real_mode_pages, (unsigned long) prot_mode_mem, (unsigned) prot_mode_pages); @@ -305,11 +307,11 @@ grub_linux_boot (void) params = real_mode_mem; - grub_dprintf ("linux", "code32_start = %x, idt_desc = %lx, gdt_desc = %lx\n", + grub_dprintf (DEBUG_CHANNEL, "code32_start = %x, idt_desc = %lx, gdt_desc = %lx\n", (unsigned) params->code32_start, (unsigned long) &(idt_desc.limit), (unsigned long) &(gdt_desc.limit)); - grub_dprintf ("linux", "idt = %x:%lx, gdt = %x:%lx\n", + grub_dprintf (DEBUG_CHANNEL, "idt = %x:%lx, gdt = %x:%lx\n", (unsigned) idt_desc.limit, (unsigned long) idt_desc.base, (unsigned) gdt_desc.limit, (unsigned long) gdt_desc.base); Index: term/i386/pc/at_keyboard.c =================================================================== --- term/i386/pc/at_keyboard.c (Revision 1843) +++ term/i386/pc/at_keyboard.c (Arbeitskopie) @@ -22,6 +22,8 @@ #include #include +#define DEBUG_CHANNEL = "atkeyb"; + static short at_keyboard_status = 0; #define KEYBOARD_STATUS_SHIFT_L (1 << 0) @@ -129,7 +131,7 @@ grub_keyboard_isr (char key) return; } #ifdef DEBUG_AT_KEYBOARD - grub_dprintf ("atkeyb", "Control key 0x%0x was %s\n", key, is_make ? "pressed" : "unpressed"); + grub_dprintf (DEBUG_CHANNEL, "Control key 0x%0x was %s\n", key, is_make ? "pressed" : "unpressed"); #endif } @@ -156,7 +158,7 @@ grub_console_checkkey (void) if (code == -1) return -1; #ifdef DEBUG_AT_KEYBOARD - grub_dprintf ("atkeyb", "Detected key 0x%x\n", key); + grub_dprintf (DEBUG_CHANNEL, "Detected key 0x%x\n", key); #endif switch (code) { @@ -165,7 +167,7 @@ grub_console_checkkey (void) /* Caps lock sends scan code twice. Get the second one and discard it. */ while (grub_keyboard_getkey () == -1); #ifdef DEBUG_AT_KEYBOARD - grub_dprintf ("atkeyb", "caps_lock = %d\n", !!(at_keyboard_status & KEYBOARD_STATUS_CAPS_LOCK)); + grub_dprintf (DEBUG_CHANNEL, "caps_lock = %d\n", !!(at_keyboard_status & KEYBOARD_STATUS_CAPS_LOCK)); #endif key = -1; break; @@ -179,7 +181,7 @@ grub_console_checkkey (void) key = keyboard_map[code]; if (key == 0) - grub_dprintf ("atkeyb", "Unknown key 0x%x detected\n", code); + grub_dprintf (DEBUG_CHANNEL, "Unknown key 0x%x detected\n", code); if (at_keyboard_status & KEYBOARD_STATUS_CAPS_LOCK) {