new static const char[] modname
PATCH 1/1 new static const char[] modname
Javier brought up [0], with his drivemap patch, the idea to use static const char[] modname = "module name"
Here's now a patch for a few files I found where this seems to be useful.
I don't think it's useful to add the variable for files which ends up in a file.mod but where it's not used at all.
If you think different I am willing to do it for the whole codebase, this is work but easy and I have time so this seems to be something for me :)
ChangeLog was as always the bigger problem ;)
From the previous entrys I wasn't that sure if it's now to spartan or how I actually should do it.
[0] http://lists.gnu.org/archive/html/grub-devel/2008-08/msg00380.html
Signature · 1 line
Felix Zielcke
2008-08-28 Felix Zielcke <[email protected]>
* disk/lvm.c (modname): Add new static variable.
* disk/scsi.c (modname): Likewise.
* disk/ata.c (modname): Likewise.
* disk/i386/pc/biosdisk.c (modname): Likewise.
* disk/host.c (modname): Likewise.
* disk/raid.c (modname): Likewise.
* disk/efi/efidisk.c (modname): Likewise.
* disk/memdisk.c (modname): Likewise.
lvm.c +3 -1
@@ -24,6 +24,8 @@#include <grub/misc.h> #include <grub/lvm.h> +static const char[] modname = "lvm"; +static struct grub_lvm_vg *vg_list;static int lv_count;
@@ -569,7 +571,7 @@ grub_lvm_scan_device (const char *name)static struct grub_disk_dev grub_lvm_dev = { - .name ="lvm" , + .name = modname, .id =GRUB_DISK_DEVICE_LVM_ID , .iterate = grub_lvm_iterate, .open = grub_lvm_open,
scsi.c +9 -7
@@ -27,6 +27,8 @@#include <grub/scsi.h> #include <grub/scsicmd.h> +static const char modname[] ="scsi" ; +static grub_scsi_dev_t grub_scsi_dev_list;
@@ -248,7 +250,7 @@ grub_scsi_open (const char *name, grub_d {if (! p->open (name, scsi)) { - disk->id = (unsigned long )"scsi" ;/* XXX */ + disk->id = (unsigned long ) modname;/* XXX */ disk->data = scsi; scsi->dev = p; scsi->lun = lun;
@@ -259,17 +261,17 @@ grub_scsi_open (const char *name, grub_dreturn grub_errno; } -grub_dprintf ("scsi" ,"dev opened\n" ); +grub_dprintf (modname,"dev opened\n" ); err =grub_scsi_inquiry (scsi);if (err) { -grub_dprintf ("scsi" ,"inquiry failed\n" ); +grub_dprintf (modname,"inquiry failed\n" ); p->close (scsi);return grub_errno; } -grub_dprintf ("scsi" ,"inquiry: devtype=0x%02x removable=%d\n" , +grub_dprintf (modname,"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 (modname,"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 (modname,"capacity=%d, blksize=%d\n" , (int ) disk->total_sectors, scsi->blocksize);return GRUB_ERR_NONE ;
@@ -364,7 +366,7 @@ grub_scsi_write (grub_disk_t disk __attrstatic struct grub_disk_dev grub_scsi_dev = { - .name ="scsi" , + .name = modname, .id =GRUB_DISK_DEVICE_SCSI_ID , .iterate = grub_scsi_iterate, .open = grub_scsi_open,
ata.c +14 -12
@@ -27,6 +27,8 @@/* XXX: For now this only works on i386. */ #include <grub/cpu/io.h> +static const char modname = modname; + 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 (modname,"Serial: %s\n" , text);grub_ata_strncpy (text, info +46 ,8 ); -grub_dprintf ("ata" ,"Firmware: %s\n" , text); +grub_dprintf (modname,"Firmware: %s\n" , text);grub_ata_strncpy (text, info +54 ,40 ); -grub_dprintf ("ata" ,"Model: %s\n" , text); +grub_dprintf (modname,"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 (modname,"Addressing: %d\n" , dev->addr); +grub_dprintf (modname,"Sectors: %lld\n" , dev->size); } }
@@ -399,7 +401,7 @@ grub_ata_device_initialize (int port, instruct grub_ata_device *dev;struct grub_ata_device **devp; -grub_dprintf ("ata" ,"detecting device %d,%d (0x%x, 0x%x)\n" , +grub_dprintf (modname,"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 (modname, "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 (modname,"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 (modname,"ATA detected\n" ); } else { -grub_dprintf ("ata" ,"incorrect signature\n" ); +grub_dprintf (modname,"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 (modname,"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 (modname,"opening ATAPI dev `%s'\n" , name);if (! devfnd)return grub_error (GRUB_ERR_UNKNOWN_DEVICE ,"No such ATAPI device" );
host.c +5 -3
@@ -24,6 +24,8 @@#include <grub/disk.h> #include <grub/misc.h> +static const char[] modname = "host"; +int grub_disk_host_i_want_a_reference; static int
@@ -37,11 +39,11 @@ grub_host_iterate (int (*hook) (const chstatic grub_err_t grub_host_open (const char *name,grub_disk_t disk) { -if (grub_strcmp (name,"host" )) +if (grub_strcmp (name, modname))return grub_error (GRUB_ERR_UNKNOWN_DEVICE ,"not a host disk" ); disk->total_sectors =0 ; - disk->id = (unsigned long )"host" ; + disk->id = (unsigned long ) modname; disk->has_partitions =0 ; disk->data =0 ;
@@ -75,7 +77,7 @@ grub_host_write (grub_disk_t disk __attrstatic struct grub_disk_dev grub_host_dev = {/* The only important line in this file :-) */ - .name ="host" , + .name = modname, .id =GRUB_DISK_DEVICE_HOST_ID , .iterate = grub_host_iterate, .open = grub_host_open,
raid.c +7 -5
@@ -24,6 +24,8 @@#include <grub/misc.h> #include <grub/raid.h> +static const char[] modname = modname; +/* 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 (modname,"%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_dbreak ; } -grub_dprintf ("raid" ,"%s: level=%d, total_sectors=%lld\n" , name, +grub_dprintf (modname,"%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 ggrub_sprintf (array->name,"md%d" , array->number); -grub_dprintf ("raid" ,"Found array %s (%s)\n" , array->name, +grub_dprintf (modname,"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 (modname,"Scanning for RAID devices\n" ); disk =grub_disk_open (name);if (!disk)
@@ -692,7 +694,7 @@ grub_raid_rescan (void)static struct grub_disk_dev grub_raid_dev = { - .name ="raid" , + .name = modname, .id =GRUB_DISK_DEVICE_RAID_ID , .iterate = grub_raid_iterate, .open = grub_raid_open,
efi/efidisk.c +12 -10
@@ -27,6 +27,8 @@#include <grub/efi/efi.h> #include <grub/efi/disk.h> +static const char[] modname = modname; +struct grub_efidisk_data {grub_efi_handle_t handle;
@@ -441,7 +443,7 @@ grub_efidisk_iterate (int (*hook) (constfor (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 (modname,"iterating %s\n" , buf);if (hook (buf))return 1 ; }
@@ -449,7 +451,7 @@ grub_efidisk_iterate (int (*hook) (constfor (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 (modname,"iterating %s\n" , buf);if (hook (buf))return 1 ; }
@@ -457,7 +459,7 @@ grub_efidisk_iterate (int (*hook) (constfor (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 (modname,"iterating %s\n" , buf);if (hook (buf))return 1 ; }
@@ -505,7 +507,7 @@ grub_efidisk_open (const char *name, strstruct grub_efidisk_data *d =0 ;grub_efi_block_io_media_t *m; -grub_dprintf ("efidisk" ,"opening %s\n" , name); +grub_dprintf (modname,"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 (modname,"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 (modname,"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 (modname,"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 (modname,"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 (modname,"writing 0x%lx sectors at the sector 0x%llx to %s\n" , (unsigned long ) size, (unsigned long long ) sector, disk->name);
@@ -614,7 +616,7 @@ grub_efidisk_write (struct grub_disk *distatic struct grub_disk_dev grub_efidisk_dev = { - .name ="efidisk" , + .name = modname, .id =GRUB_DISK_DEVICE_EFIDISK_ID , .iterate = grub_efidisk_iterate, .open = grub_efidisk_open,
memdisk.c +7 -5
@@ -25,19 +25,21 @@#include <grub/types.h> #include <grub/machine/kernel.h> +static const char[] modname = "memdisk"; +static char *memdisk_addr;static grub_off_t memdisk_size =0 ;static int grub_memdisk_iterate (int (*hook) (const char *name)) { -return hook ("memdisk" ); +return hook (modname); }static grub_err_t grub_memdisk_open (const char *name,grub_disk_t disk) { -if (grub_strcmp (name,"memdisk" )) +if (grub_strcmp (name, modname))return grub_error (GRUB_ERR_UNKNOWN_DEVICE ,"not a memdisk" ); disk->total_sectors = memdisk_size /GRUB_DISK_SECTOR_SIZE ;
@@ -70,7 +72,7 @@ grub_memdisk_write (grub_disk_t disk __astatic struct grub_disk_dev grub_memdisk_dev = { - .name ="memdisk" , + .name = modname, .id =GRUB_DISK_DEVICE_MEMDISK_ID , .iterate = grub_memdisk_iterate, .open = grub_memdisk_open,
@@ -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 (modname,"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 (modname,"Copying memdisk image to dynamic memory\n" );grub_memmove (memdisk_addr, memdisk_orig_addr, memdisk_size);grub_disk_dev_register (&grub_memdisk_dev);
Seems like it isn't that bad to review your own patches _before_ sending them and actually to compile them ..
Signature · 1 line
Felix Zielcke
lvm.c +3 -1
@@ -24,6 +24,8 @@#include <grub/misc.h> #include <grub/lvm.h> +static const char modname[] ="lvm" ; +static struct grub_lvm_vg *vg_list;static int lv_count;
@@ -569,7 +571,7 @@ grub_lvm_scan_device (const char *name)static struct grub_disk_dev grub_lvm_dev = { - .name ="lvm" , + .name = modname, .id =GRUB_DISK_DEVICE_LVM_ID , .iterate = grub_lvm_iterate, .open = grub_lvm_open,
scsi.c +9 -7
@@ -27,6 +27,8 @@#include <grub/scsi.h> #include <grub/scsicmd.h> +static const char modname[] ="scsi" ; +static grub_scsi_dev_t grub_scsi_dev_list;
@@ -248,7 +250,7 @@ grub_scsi_open (const char *name, grub_d {if (! p->open (name, scsi)) { - disk->id = (unsigned long )"scsi" ;/* XXX */ + disk->id = (unsigned long ) modname;/* XXX */ disk->data = scsi; scsi->dev = p; scsi->lun = lun;
@@ -259,17 +261,17 @@ grub_scsi_open (const char *name, grub_dreturn grub_errno; } -grub_dprintf ("scsi" ,"dev opened\n" ); +grub_dprintf (modname,"dev opened\n" ); err =grub_scsi_inquiry (scsi);if (err) { -grub_dprintf ("scsi" ,"inquiry failed\n" ); +grub_dprintf (modname,"inquiry failed\n" ); p->close (scsi);return grub_errno; } -grub_dprintf ("scsi" ,"inquiry: devtype=0x%02x removable=%d\n" , +grub_dprintf (modname,"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 (modname,"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 (modname,"capacity=%d, blksize=%d\n" , (int ) disk->total_sectors, scsi->blocksize);return GRUB_ERR_NONE ;
@@ -364,7 +366,7 @@ grub_scsi_write (grub_disk_t disk __attrstatic struct grub_disk_dev grub_scsi_dev = { - .name ="scsi" , + .name = modname, .id =GRUB_DISK_DEVICE_SCSI_ID , .iterate = grub_scsi_iterate, .open = grub_scsi_open,
ata.c +14 -12
@@ -27,6 +27,8 @@/* XXX: For now this only works on i386. */ #include <grub/cpu/io.h> +static const char modname[] ="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 (modname,"Serial: %s\n" , text);grub_ata_strncpy (text, info +46 ,8 ); -grub_dprintf ("ata" ,"Firmware: %s\n" , text); +grub_dprintf (modname,"Firmware: %s\n" , text);grub_ata_strncpy (text, info +54 ,40 ); -grub_dprintf ("ata" ,"Model: %s\n" , text); +grub_dprintf (modname,"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 (modname,"Addressing: %d\n" , dev->addr); +grub_dprintf (modname,"Sectors: %lld\n" , dev->size); } }
@@ -399,7 +401,7 @@ grub_ata_device_initialize (int port, instruct grub_ata_device *dev;struct grub_ata_device **devp; -grub_dprintf ("ata" ,"detecting device %d,%d (0x%x, 0x%x)\n" , +grub_dprintf (modname,"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 (modname, "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 (modname,"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 (modname,"ATA detected\n" ); } else { -grub_dprintf ("ata" ,"incorrect signature\n" ); +grub_dprintf (modname,"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 (modname,"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 (modname,"opening ATAPI dev `%s'\n" , name);if (! devfnd)return grub_error (GRUB_ERR_UNKNOWN_DEVICE ,"No such ATAPI device" );
host.c +5 -3
@@ -24,6 +24,8 @@#include <grub/disk.h> #include <grub/misc.h> +static const char[] modname = "host"; +int grub_disk_host_i_want_a_reference; static int
@@ -37,11 +39,11 @@ grub_host_iterate (int (*hook) (const chstatic grub_err_t grub_host_open (const char *name,grub_disk_t disk) { -if (grub_strcmp (name,"host" )) +if (grub_strcmp (name, modname))return grub_error (GRUB_ERR_UNKNOWN_DEVICE ,"not a host disk" ); disk->total_sectors =0 ; - disk->id = (unsigned long )"host" ; + disk->id = (unsigned long ) modname; disk->has_partitions =0 ; disk->data =0 ;
@@ -75,7 +77,7 @@ grub_host_write (grub_disk_t disk __attrstatic struct grub_disk_dev grub_host_dev = {/* The only important line in this file :-) */ - .name ="host" , + .name = modname, .id =GRUB_DISK_DEVICE_HOST_ID , .iterate = grub_host_iterate, .open = grub_host_open,
raid.c +7 -5
@@ -24,6 +24,8 @@#include <grub/misc.h> #include <grub/raid.h> +static const char modname[] ="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 (modname,"%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_dbreak ; } -grub_dprintf ("raid" ,"%s: level=%d, total_sectors=%lld\n" , name, +grub_dprintf (modname,"%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 ggrub_sprintf (array->name,"md%d" , array->number); -grub_dprintf ("raid" ,"Found array %s (%s)\n" , array->name, +grub_dprintf (modname,"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 (modname,"Scanning for RAID devices\n" ); disk =grub_disk_open (name);if (!disk)
@@ -692,7 +694,7 @@ grub_raid_rescan (void)static struct grub_disk_dev grub_raid_dev = { - .name ="raid" , + .name = modname, .id =GRUB_DISK_DEVICE_RAID_ID , .iterate = grub_raid_iterate, .open = grub_raid_open,
efi/efidisk.c +12 -10
@@ -27,6 +27,8 @@#include <grub/efi/efi.h> #include <grub/efi/disk.h> +static const char[] modname = "efidisk"; +struct grub_efidisk_data {grub_efi_handle_t handle;
@@ -441,7 +443,7 @@ grub_efidisk_iterate (int (*hook) (constfor (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 (modname,"iterating %s\n" , buf);if (hook (buf))return 1 ; }
@@ -449,7 +451,7 @@ grub_efidisk_iterate (int (*hook) (constfor (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 (modname,"iterating %s\n" , buf);if (hook (buf))return 1 ; }
@@ -457,7 +459,7 @@ grub_efidisk_iterate (int (*hook) (constfor (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 (modname,"iterating %s\n" , buf);if (hook (buf))return 1 ; }
@@ -505,7 +507,7 @@ grub_efidisk_open (const char *name, strstruct grub_efidisk_data *d =0 ;grub_efi_block_io_media_t *m; -grub_dprintf ("efidisk" ,"opening %s\n" , name); +grub_dprintf (modname,"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 (modname,"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 (modname,"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 (modname,"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 (modname,"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 (modname,"writing 0x%lx sectors at the sector 0x%llx to %s\n" , (unsigned long ) size, (unsigned long long ) sector, disk->name);
@@ -614,7 +616,7 @@ grub_efidisk_write (struct grub_disk *distatic struct grub_disk_dev grub_efidisk_dev = { - .name ="efidisk" , + .name = modname, .id =GRUB_DISK_DEVICE_EFIDISK_ID , .iterate = grub_efidisk_iterate, .open = grub_efidisk_open,
memdisk.c +7 -5
@@ -25,19 +25,21 @@#include <grub/types.h> #include <grub/machine/kernel.h> +static const char modname[] ="memdisk" ; +static char *memdisk_addr;static grub_off_t memdisk_size =0 ;static int grub_memdisk_iterate (int (*hook) (const char *name)) { -return hook ("memdisk" ); +return hook (modname); }static grub_err_t grub_memdisk_open (const char *name,grub_disk_t disk) { -if (grub_strcmp (name,"memdisk" )) +if (grub_strcmp (name, modname))return grub_error (GRUB_ERR_UNKNOWN_DEVICE ,"not a memdisk" ); disk->total_sectors = memdisk_size /GRUB_DISK_SECTOR_SIZE ;
@@ -70,7 +72,7 @@ grub_memdisk_write (grub_disk_t disk __astatic struct grub_disk_dev grub_memdisk_dev = { - .name ="memdisk" , + .name = modname, .id =GRUB_DISK_DEVICE_MEMDISK_ID , .iterate = grub_memdisk_iterate, .open = grub_memdisk_open,
@@ -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 (modname,"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 (modname,"Copying memdisk image to dynamic memory\n" );grub_memmove (memdisk_addr, memdisk_orig_addr, memdisk_size);grub_disk_dev_register (&grub_memdisk_dev);
biosdisk.c +1 -0
@@ -127,6 +127,7 @@ find_grub_drive (const char *name)static int find_free_slot () { +int i;for (i =0 ; i <sizeof (map) /sizeof (map[0 ]); i++)if (! map[i].drive)return i;
Quoted 2 lines · Felix Zielcke
Seems like it isn't that bad to review your own patches _before_ sending them and actually to compile them ..
...and include a changelog entry? ;-)
--
Marco
Am Donnerstag, den 28.08.2008, 20:31 +0200 schrieb Marco Gerards:
Quoted 6 lines
Quoted 2 lines · Felix Zielcke
Seems like it isn't that bad to review your own patches _before_ sending them and actually to compile them ..
...and include a changelog entry? ;-)
That's evolution's fault.
In the file it was already included, but I added it to the mail just before I sent it. Oh well maybe again mine.
The first one had the changelog entry *sigh*
Well use the now attached one.
2008-08-28 Felix Zielcke <[email protected]>
* disk/lvm.c (modname): Add new static variable.
* disk/scsi.c (modname): Likewise.
* disk/ata.c (modname): Likewise.
* disk/i386/pc/biosdisk.c (modname): Likewise.
* disk/host.c (modname): Likewise.
* disk/raid.c (modname): Likewise.
* disk/efi/efidisk.c (modname): Likewise.
* disk/memdisk.c (modname): Likewise.
lvm.c +3 -1
@@ -24,6 +24,8 @@#include <grub/misc.h> #include <grub/lvm.h> +static const char modname[] ="lvm" ; +static struct grub_lvm_vg *vg_list;static int lv_count;
@@ -569,7 +571,7 @@ grub_lvm_scan_device (const char *name)static struct grub_disk_dev grub_lvm_dev = { - .name ="lvm" , + .name = modname, .id =GRUB_DISK_DEVICE_LVM_ID , .iterate = grub_lvm_iterate, .open = grub_lvm_open,
scsi.c +9 -7
@@ -27,6 +27,8 @@#include <grub/scsi.h> #include <grub/scsicmd.h> +static const char modname[] ="scsi" ; +static grub_scsi_dev_t grub_scsi_dev_list;
@@ -248,7 +250,7 @@ grub_scsi_open (const char *name, grub_d {if (! p->open (name, scsi)) { - disk->id = (unsigned long )"scsi" ;/* XXX */ + disk->id = (unsigned long ) modname;/* XXX */ disk->data = scsi; scsi->dev = p; scsi->lun = lun;
@@ -259,17 +261,17 @@ grub_scsi_open (const char *name, grub_dreturn grub_errno; } -grub_dprintf ("scsi" ,"dev opened\n" ); +grub_dprintf (modname,"dev opened\n" ); err =grub_scsi_inquiry (scsi);if (err) { -grub_dprintf ("scsi" ,"inquiry failed\n" ); +grub_dprintf (modname,"inquiry failed\n" ); p->close (scsi);return grub_errno; } -grub_dprintf ("scsi" ,"inquiry: devtype=0x%02x removable=%d\n" , +grub_dprintf (modname,"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 (modname,"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 (modname,"capacity=%d, blksize=%d\n" , (int ) disk->total_sectors, scsi->blocksize);return GRUB_ERR_NONE ;
@@ -364,7 +366,7 @@ grub_scsi_write (grub_disk_t disk __attrstatic struct grub_disk_dev grub_scsi_dev = { - .name ="scsi" , + .name = modname, .id =GRUB_DISK_DEVICE_SCSI_ID , .iterate = grub_scsi_iterate, .open = grub_scsi_open,
ata.c +14 -12
@@ -27,6 +27,8 @@/* XXX: For now this only works on i386. */ #include <grub/cpu/io.h> +static const char modname[] ="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 (modname,"Serial: %s\n" , text);grub_ata_strncpy (text, info +46 ,8 ); -grub_dprintf ("ata" ,"Firmware: %s\n" , text); +grub_dprintf (modname,"Firmware: %s\n" , text);grub_ata_strncpy (text, info +54 ,40 ); -grub_dprintf ("ata" ,"Model: %s\n" , text); +grub_dprintf (modname,"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 (modname,"Addressing: %d\n" , dev->addr); +grub_dprintf (modname,"Sectors: %lld\n" , dev->size); } }
@@ -399,7 +401,7 @@ grub_ata_device_initialize (int port, instruct grub_ata_device *dev;struct grub_ata_device **devp; -grub_dprintf ("ata" ,"detecting device %d,%d (0x%x, 0x%x)\n" , +grub_dprintf (modname,"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 (modname, "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 (modname,"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 (modname,"ATA detected\n" ); } else { -grub_dprintf ("ata" ,"incorrect signature\n" ); +grub_dprintf (modname,"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 (modname,"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 (modname,"opening ATAPI dev `%s'\n" , name);if (! devfnd)return grub_error (GRUB_ERR_UNKNOWN_DEVICE ,"No such ATAPI device" );
host.c +5 -3
@@ -24,6 +24,8 @@#include <grub/disk.h> #include <grub/misc.h> +static const char[] modname = "host"; +int grub_disk_host_i_want_a_reference; static int
@@ -37,11 +39,11 @@ grub_host_iterate (int (*hook) (const chstatic grub_err_t grub_host_open (const char *name,grub_disk_t disk) { -if (grub_strcmp (name,"host" )) +if (grub_strcmp (name, modname))return grub_error (GRUB_ERR_UNKNOWN_DEVICE ,"not a host disk" ); disk->total_sectors =0 ; - disk->id = (unsigned long )"host" ; + disk->id = (unsigned long ) modname; disk->has_partitions =0 ; disk->data =0 ;
@@ -75,7 +77,7 @@ grub_host_write (grub_disk_t disk __attrstatic struct grub_disk_dev grub_host_dev = {/* The only important line in this file :-) */ - .name ="host" , + .name = modname, .id =GRUB_DISK_DEVICE_HOST_ID , .iterate = grub_host_iterate, .open = grub_host_open,
raid.c +7 -5
@@ -24,6 +24,8 @@#include <grub/misc.h> #include <grub/raid.h> +static const char modname[] ="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 (modname,"%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_dbreak ; } -grub_dprintf ("raid" ,"%s: level=%d, total_sectors=%lld\n" , name, +grub_dprintf (modname,"%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 ggrub_sprintf (array->name,"md%d" , array->number); -grub_dprintf ("raid" ,"Found array %s (%s)\n" , array->name, +grub_dprintf (modname,"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 (modname,"Scanning for RAID devices\n" ); disk =grub_disk_open (name);if (!disk)
@@ -692,7 +694,7 @@ grub_raid_rescan (void)static struct grub_disk_dev grub_raid_dev = { - .name ="raid" , + .name = modname, .id =GRUB_DISK_DEVICE_RAID_ID , .iterate = grub_raid_iterate, .open = grub_raid_open,
efi/efidisk.c +12 -10
@@ -27,6 +27,8 @@#include <grub/efi/efi.h> #include <grub/efi/disk.h> +static const char[] modname = "efidisk"; +struct grub_efidisk_data {grub_efi_handle_t handle;
@@ -441,7 +443,7 @@ grub_efidisk_iterate (int (*hook) (constfor (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 (modname,"iterating %s\n" , buf);if (hook (buf))return 1 ; }
@@ -449,7 +451,7 @@ grub_efidisk_iterate (int (*hook) (constfor (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 (modname,"iterating %s\n" , buf);if (hook (buf))return 1 ; }
@@ -457,7 +459,7 @@ grub_efidisk_iterate (int (*hook) (constfor (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 (modname,"iterating %s\n" , buf);if (hook (buf))return 1 ; }
@@ -505,7 +507,7 @@ grub_efidisk_open (const char *name, strstruct grub_efidisk_data *d =0 ;grub_efi_block_io_media_t *m; -grub_dprintf ("efidisk" ,"opening %s\n" , name); +grub_dprintf (modname,"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 (modname,"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 (modname,"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 (modname,"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 (modname,"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 (modname,"writing 0x%lx sectors at the sector 0x%llx to %s\n" , (unsigned long ) size, (unsigned long long ) sector, disk->name);
@@ -614,7 +616,7 @@ grub_efidisk_write (struct grub_disk *distatic struct grub_disk_dev grub_efidisk_dev = { - .name ="efidisk" , + .name = modname, .id =GRUB_DISK_DEVICE_EFIDISK_ID , .iterate = grub_efidisk_iterate, .open = grub_efidisk_open,
memdisk.c +7 -5
@@ -25,19 +25,21 @@#include <grub/types.h> #include <grub/machine/kernel.h> +static const char modname[] ="memdisk" ; +static char *memdisk_addr;static grub_off_t memdisk_size =0 ;static int grub_memdisk_iterate (int (*hook) (const char *name)) { -return hook ("memdisk" ); +return hook (modname); }static grub_err_t grub_memdisk_open (const char *name,grub_disk_t disk) { -if (grub_strcmp (name,"memdisk" )) +if (grub_strcmp (name, modname))return grub_error (GRUB_ERR_UNKNOWN_DEVICE ,"not a memdisk" ); disk->total_sectors = memdisk_size /GRUB_DISK_SECTOR_SIZE ;
@@ -70,7 +72,7 @@ grub_memdisk_write (grub_disk_t disk __astatic struct grub_disk_dev grub_memdisk_dev = { - .name ="memdisk" , + .name = modname, .id =GRUB_DISK_DEVICE_MEMDISK_ID , .iterate = grub_memdisk_iterate, .open = grub_memdisk_open,
@@ -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 (modname,"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 (modname,"Copying memdisk image to dynamic memory\n" );grub_memmove (memdisk_addr, memdisk_orig_addr, memdisk_size);grub_disk_dev_register (&grub_memdisk_dev);
scsi.c grub_scsi_open (const char *name, grub_d · line 253
Quoted 6 lines · Felix Zielcke
scsi.c +1
-1@@ -248,7 +250,7 @@ grub_scsi_open (const char *name, grub_d {if (! p->open (name, scsi)) { - disk->id = (unsigned long )"scsi" ;/* XXX */ + disk->id = (unsigned long ) modname;/* XXX */
I think the idea with this was to unify the strings for grub_dprintf calls; your patch goes a bit further and also puts other sort of strings to share the same variable.
I think that's a bit dangerous, since changes intended for one use of the variable could collaterally affect the rest in subtle ways. And it's not that useful in code size anyway.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Am Samstag, den 30.08.2008, 14:01 +0200 schrieb Robert Millan:
Quoted 7 lines
I think the idea with this was to unify the strings for
grub_dprintfcalls; your patch goes a bit further and also puts other sort of strings to share the same variable.I think that's a bit dangerous, since changes intended for one use of the variable could collaterally affect the rest in subtle ways. And it's not that useful in code size anyway.
Oh right, but then modname seems to be a bit the wrong name, if it should ony be used for grub_dprintf.
For example the i386-pc biosdisc.c uses grub_dprintf("disk") and partmap/pc.c uses "partition"
What about moddebugname or something like that then?
Signature · 1 line
Felix Zielcke
Quoted 10 lines · Felix Zielcke
Am Samstag, den 30.08.2008, 14:01 +0200 schrieb Robert Millan:
Quoted 7 lines
I think the idea with this was to unify the strings for
grub_dprintfcalls; your patch goes a bit further and also puts other sort of strings to share the same variable.I think that's a bit dangerous, since changes intended for one use of the variable could collaterally affect the rest in subtle ways. And it's not that useful in code size anyway.
Quoted 6 lines
Oh right, but then modname seems to be a bit the wrong name, if it should ony be used for
grub_dprintf.
For example the i386-pcbiosdisc.cusesgrub_dprintf("disk")andpartmap/pc.cuses "partition"What about moddebugname or something like that then?
grub_dprintf itself refers to that as "condition". I'd personally prefer "channel" though. What do others think?
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Re: [PATCH] new static const char[] channel (was: modname)
Am Samstag, den 30.08.2008, 14:42 +0200 schrieb Robert Millan:
Quoted 3 lines
grub_dprintfitself refers to that as "condition". I'd personally prefer "channel" though. What do others think?
I used now just channel, if others have better suggestions a s/channel/whatever shouldn't be too difficult.
The only grub_dprintf calls that I haven't touched now are in fs/reiserfs.c
It uses "reiserfs" and "reiserfs_tree", I wasn't sure if I should merge them or make a channel2="reiserfs_tree"
fz:/boot/grub# /bin/ls -l core.img -rw-r--r-- 1 root root 25171 31. Aug 19:39 core.img fz:/boot/grub# /bin/ls -l core.img -rw-r--r-- 1 root root 25153 1. Sep 13:19 core.img
Phew that was it worth :)
Signature · 1 line
Felix Zielcke
2008-09-01 Felix Zielcke <[email protected]>
* disk/scsi.c (channel): Add new static variable. Update all grub_dprintf' calls to use 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.
scsi.c +7 -5
@@ -28,6 +28,8 @@#include <grub/scsicmd.h> +static const char channel[] ="scsi" ; +static grub_scsi_dev_t grub_scsi_dev_list;void
@@ -259,17 +261,17 @@ grub_scsi_open (const char *name, grub_dreturn grub_errno; } -grub_dprintf ("scsi" ,"dev opened\n" ); +grub_dprintf (channel,"dev opened\n" ); err =grub_scsi_inquiry (scsi);if (err) { -grub_dprintf ("scsi" ,"inquiry failed\n" ); +grub_dprintf (channel,"inquiry failed\n" ); p->close (scsi);return grub_errno; } -grub_dprintf ("scsi" ,"inquiry: devtype=0x%02x removable=%d\n" , +grub_dprintf (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 (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 (channel,"capacity=%d, blksize=%d\n" , (int ) disk->total_sectors, scsi->blocksize);return GRUB_ERR_NONE ;
ieee1275/ofdisk.c +11 -9
@@ -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 <grub/ieee1275/ieee1275.h> #include <grub/ieee1275/ofdisk.h> +static const char channel[] ="disk" ; +static int grub_ofdisk_iterate (int (*hook) (const char *name)) {
@@ -30,7 +32,7 @@ grub_ofdisk_iterate (int (*hook) (constint dev_iterate (struct grub_ieee1275_devalias *alias) { -grub_dprintf ("disk" ,"disk name = %s\n" , alias->name); +grub_dprintf (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) (constif (grub_ieee1275_finddevice (alias->path, &dev)) { -grub_dprintf ("disk" ,"finddevice (%s) failed\n" , alias->path); +grub_dprintf (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 (channel,"get iconname failed\n" );return 0 ; }if (grub_strcmp (tmp,"sdmmc" )) { -grub_dprintf ("disk" ,"device is not an SD card\n" ); +grub_dprintf (channel,"device is not an SD card\n" );return 0 ; } }
@@ -89,7 +91,7 @@ grub_ofdisk_open (const char *name, grubif (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0 ))grub_strcat (devpath,":0" ); -grub_dprintf ("disk" ,"Opening `%s'.\n" , devpath); +grub_dprintf (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 (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, grubstatic void grub_ofdisk_close (grub_disk_t disk) { -grub_dprintf ("disk" ,"Closing handle %p.\n" , +grub_dprintf (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, grubgrub_ssize_t status, actual;unsigned long long pos; -grub_dprintf ("disk" , +grub_dprintf (channel,"Reading handle %p: sector 0x%llx, size 0x%lx, buf %p.\n" , (void *) disk->data, sector, (long ) size, buf);
ata.c +14 -12
@@ -27,6 +27,8 @@/* XXX: For now this only works on i386. */ #include <grub/cpu/io.h> +static const char 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 (channel,"Serial: %s\n" , text);grub_ata_strncpy (text, info +46 ,8 ); -grub_dprintf ("ata" ,"Firmware: %s\n" , text); +grub_dprintf (channel,"Firmware: %s\n" , text);grub_ata_strncpy (text, info +54 ,40 ); -grub_dprintf ("ata" ,"Model: %s\n" , text); +grub_dprintf (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 (channel,"Addressing: %d\n" , dev->addr); +grub_dprintf (channel,"Sectors: %lld\n" , dev->size); } }
@@ -399,7 +401,7 @@ grub_ata_device_initialize (int port, instruct grub_ata_device *dev;struct grub_ata_device **devp; -grub_dprintf ("ata" ,"detecting device %d,%d (0x%x, 0x%x)\n" , +grub_dprintf (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 (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 (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 (channel,"ATA detected\n" ); } else { -grub_dprintf ("ata" ,"incorrect signature\n" ); +grub_dprintf (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 (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 (channel,"opening ATAPI dev `%s'\n" , name);if (! devfnd)return grub_error (GRUB_ERR_UNKNOWN_DEVICE ,"No such ATAPI device" );
i386/pc/biosdisk.c +3 -1
@@ -27,6 +27,8 @@#include <grub/err.h> #include <grub/term.h> +static const char channel[] ="disk" ; +static int cd_drive =0 ; static int
@@ -72,7 +74,7 @@ grub_biosdisk_iterate (int (*hook) (consif (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 (channel,"Read error when probing drive 0x%2x\n" , drive);break ; }
raid.c +6 -4
@@ -24,6 +24,8 @@#include <grub/misc.h> #include <grub/raid.h> +static const char 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 (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_dbreak ; } -grub_dprintf ("raid" ,"%s: level=%d, total_sectors=%lld\n" , name, +grub_dprintf (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 ggrub_sprintf (array->name,"md%d" , array->number); -grub_dprintf ("raid" ,"Found array %s (%s)\n" , array->name, +grub_dprintf (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 (channel,"Scanning for RAID devices\n" ); disk =grub_disk_open (name);if (!disk)
efi/efidisk.c +12 -10
@@ -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 <grub/efi/efi.h> #include <grub/efi/disk.h> +static const char channel[] ="efidisk" ; +struct grub_efidisk_data {grub_efi_handle_t handle;
@@ -441,7 +443,7 @@ grub_efidisk_iterate (int (*hook) (constfor (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 (channel,"iterating %s\n" , buf);if (hook (buf))return 1 ; }
@@ -449,7 +451,7 @@ grub_efidisk_iterate (int (*hook) (constfor (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 (channel,"iterating %s\n" , buf);if (hook (buf))return 1 ; }
@@ -457,7 +459,7 @@ grub_efidisk_iterate (int (*hook) (constfor (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 (channel,"iterating %s\n" , buf);if (hook (buf))return 1 ; }
@@ -505,7 +507,7 @@ grub_efidisk_open (const char *name, strstruct grub_efidisk_data *d =0 ;grub_efi_block_io_media_t *m; -grub_dprintf ("efidisk" ,"opening %s\n" , name); +grub_dprintf (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 (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 (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 (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 (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 (channel,"writing 0x%lx sectors at the sector 0x%llx to %s\n" , (unsigned long ) size, (unsigned long long ) sector, disk->name);
memdisk.c +4 -2
@@ -25,6 +25,8 @@#include <grub/types.h> #include <grub/machine/kernel.h> +static const char 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 (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 (channel,"Copying memdisk image to dynamic memory\n" );grub_memmove (memdisk_addr, memdisk_orig_addr, memdisk_size);grub_disk_dev_register (&grub_memdisk_dev);
dl.c +8 -6
@@ -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 <grub/env.h> #include <grub/cache.h> +static const char 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 (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_sizeElf_Ehdr *e;grub_dl_t mod; -grub_dprintf ("modules" ,"module at %p, size 0x%lx\n" , addr, +grub_dprintf (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 (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_sizegrub_dl_flush_cache (mod); -grub_dprintf ("modules" ,"module name: %s\n" , mod->name); -grub_dprintf ("modules" ,"init function: %p\n" , mod->init); +grub_dprintf (channel,"module name: %s\n" , mod->name); +grub_dprintf (channel,"init function: %p\n" , mod->init);grub_dl_call_init (mod);if (grub_dl_add (mod))
sparc64/ieee1275/openfw.c +6 -4
@@ -23,6 +23,8 @@#include <grub/machine/kernel.h> /* Needed ? */ #include <grub/ieee1275/ieee1275.h> +static const char channel[] ="devalias" ; +enum grub_ieee1275_parse_type {GRUB_PARSE_FILENAME ,
@@ -105,7 +107,7 @@ grub_devalias_iterate (int (*hook) (strugrub_ssize_t pathlen, typelen;char *devpath, *devtype; -grub_dprintf ("devalias" ,"devalias name = %s\n" , aliasname); +grub_dprintf (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) (struif (grub_ieee1275_get_property (devalias, aliasname, devpath, pathlen, &actual)) { -grub_dprintf ("devalias" ,"get_property (%s) failed\n" , aliasname); +grub_dprintf (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 (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 (channel,"get device type failed\n" );grub_free (devtype);grub_free (devpath);continue ;
ieee1275/openfw.c +5 -3
@@ -25,6 +25,8 @@#include <grub/machine/kernel.h> #include <grub/ieee1275/ieee1275.h> +static const char 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 (channel,"devalias name = %s\n" , aliasname);grub_ieee1275_get_property_length (aliases, aliasname, &pathlen);
@@ -118,13 +120,13 @@ grub_devalias_iterate (int (*hook) (struif (grub_ieee1275_get_property (aliases, aliasname, devpath, pathlen, &actual)) { -grub_dprintf ("devalias" ,"get_property (%s) failed\n" , aliasname); +grub_dprintf (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 (channel,"finddevice (%s) failed\n" , devpath); goto nextprop; }
elf.c +8 -6
@@ -25,6 +25,8 @@#include <grub/misc.h> #include <grub/mm.h> +static const char 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 (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 (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_eif (load_addr < load_base) load_base = load_addr; -grub_dprintf ("elf" ,"Loading segment at 0x%llx, size 0x%llx\n" , +grub_dprintf (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 (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 (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_eif (load_addr < load_base) load_base = load_addr; -grub_dprintf ("elf" ,"Loading segment at 0x%llx, size 0x%llx\n" , +grub_dprintf (channel,"Loading segment at 0x%llx, size 0x%llx\n" , (unsigned long long ) load_addr, (unsigned long long ) phdr->p_memsz);
fs.c +5 -3
@@ -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 <grub/mm.h> #include <grub/term.h> +static const char 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 (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 (channel,"%s detection failed.\n" , p->name);grub_error_pop ();if (grub_errno !=GRUB_ERR_BAD_FS )
partition.c +5 -3
@@ -20,6 +20,8 @@#include <grub/partition.h> #include <grub/disk.h> +static const char channel[] ="partition" ; +static grub_partition_map_t grub_partition_map_list;void
@@ -103,18 +105,18 @@ grub_partition_iterate (struct grub_diskint part_map_iterate (const grub_partition_map_t p) { -grub_dprintf ("partition" ,"Detecting %s...\n" , p->name); +grub_dprintf (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 (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 (channel,"%s detection succeeded.\n" , p->name); partmap = p;return 1 ; }
disk.c +9 -7
@@ -27,6 +27,8 @@#define GRUB_CACHE_TIMEOUT 2 +static const char 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 (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 (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 (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_dchar *tmp_buf;unsigned real_offset; -grub_dprintf ("disk" ,"Reading `%s'...\n" , disk->name); +grub_dprintf (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 (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_dif ((disk->dev->read) (disk, sector, num, tmp_buf)) {grub_error_push (); -grub_dprintf ("disk" ,"%s read failed\n" , disk->name); +grub_dprintf (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 (channel,"Writing `%s'...\n" , disk->name);if (grub_disk_adjust_range (disk, §or, &offset, size) !=GRUB_ERR_NONE )return -1 ;
reiserfs.c +17 -14
@@ -60,6 +60,8 @@#define S_IFLNK 0xA000 +static const char channel[] ="reiserfs" ; +#ifndef GRUB_UTIL static grub_dl_t my_mod;#endif
@@ -72,6 +74,7 @@ real_assert (int boolean, const char *figrub_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 (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 (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_nif (grub_errno) goto fail;#if 0 - grub_dprintf ("reiserfs", + grub_dprintf (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_ngrub_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 (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_nif (grub_errno) goto fail;#if 0 - grub_dprintf ("reiserfs", + grub_dprintf (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_ngrub_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 (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 (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 (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 (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 (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 (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 (channel,"Reading indirect block %u from %u to %u...\n" , (unsigned ) block, (unsigned ) offset, (unsigned ) (offset + length));#if 0 - grub_dprintf ("reiserfs", + grub_dprintf (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 (channel,"Have successfully read %lld bytes (%ld requested)\n" , (unsigned long long ) (current_position - initial_position), (unsigned long ) len);
script.c +8 -6
@@ -22,6 +22,8 @@#include <grub/parser.h> #include <grub/mm.h> +static const char 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 (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_scriptwhile (mem) { memfree = mem->next; -grub_dprintf ("scripting" ,"free %p\n" , mem); +grub_dprintf (channel,"free %p\n" , mem);grub_free (mem); mem = memfree; }
@@ -134,7 +136,7 @@ grub_script_add_arglist (struct grub_parstruct grub_script_arglist *link;struct grub_script_arglist *ll; -grub_dprintf ("scripting" ,"arglist\n" ); +grub_dprintf (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 (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 (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 (channel, "cmdblock\n");if (! cmd)return (struct grub_script_cmd *) cmdblock;
lexer.c +10 -8
@@ -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" +static const char channel[] ="scripting" ; +static int check_varstate (grub_parser_state_t state) {
@@ -181,7 +183,7 @@ grub_script_yylex2 (union YYSTYPE *yylvaif (! state->script)return 0 ; } -grub_dprintf ("scripting" ,"token=`\\n'\n" ); +grub_dprintf (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 *yylvagrub_free (state->newscript); state->newscript =0 ; state->done =1 ; -grub_dprintf ("scripting" ,"token=`\\n'\n" ); +grub_dprintf (channel,"token=`\\n'\n" );return '\n' ; } }
@@ -215,13 +217,13 @@ grub_script_yylex2 (union YYSTYPE *yylvaif (! (state->state ==GRUB_PARSER_STATE_TEXT && *state->script ==' ' )) { -grub_dprintf ("scripting" ,"token=` '\n" ); +grub_dprintf (channel,"token=` '\n" );return ' ' ; } state->state = newstate;nextchar (state); } -grub_dprintf ("scripting" ,"token=` '\n" ); +grub_dprintf (channel,"token=` '\n" );return ' ' ;case '{' :case '}' :
@@ -229,7 +231,7 @@ grub_script_yylex2 (union YYSTYPE *yylvacase '\n' : {char c; -grub_dprintf ("scripting" ,"token=`%c'\n" , *state->script); +grub_dprintf (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 (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 (channel,"vartoken=`%s'\n" , buffer);return GRUB_PARSER_TOKEN_VAR ; }
i386/pc/play.c +5 -3
@@ -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 noteshort duration; }; +static const char 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 (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 (channel,"pitch = %d, duration = %d\n" , buf.pitch, buf.duration); switch (buf.pitch)
apple.c +5 -3
@@ -25,6 +25,8 @@#define GRUB_APPLE_HEADER_MAGIC 0x4552#define GRUB_APPLE_PART_MAGIC 0x504D +static const char 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_tif (grub_be_to_cpu16 (aheader.magic) !=GRUB_APPLE_HEADER_MAGIC ) { -grub_dprintf ("partition" , +grub_dprintf (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_tif (grub_be_to_cpu16 (apart.magic) !=GRUB_APPLE_PART_MAGIC ) { -grub_dprintf ("partition" , +grub_dprintf (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 (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),
pc.c +4 -2
@@ -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 + +static const char 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 (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,
gpt.c +4 -2
@@ -25,6 +25,8 @@#include <grub/pc_partition.h> #include <grub/gpt_partition.h> +static const char 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 dif (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 (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 (channel,"GPT entry %d: start=%lld, length=%lld\n" , i, (unsigned long long ) part.start, (unsigned long long ) part.len);
powerpc/ieee1275/linux.c +11 -9
@@ -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) +static const char 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 (channel,"Entry point: 0x%x\n" , linux_addr); +grub_dprintf (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 (channel,"Boot arguments: %s\n" , linux_args); +grub_dprintf (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 (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 (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 (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 (channel,"Loading initrd at 0x%x, size 0x%x\n" , addr, size);if (grub_file_read (file, (void *) addr, size) != size) {
multiboot2.c +13 -11
@@ -30,6 +30,8 @@#include <grub/misc.h> #include <grub/gzio.h> +static const char 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 (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, igrub_size_t used;grub_size_t needed; -grub_dprintf ("loader" ,"Allocating tag: key 0x%x, size 0x%lx.\n" , +grub_dprintf (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, igrub_size_t newsize = needed *2 ;char *newarea; -grub_dprintf ("loader" ,"Reallocating tag buffer (new size 0x%lx).\n" , +grub_dprintf (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 (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 (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 aif (err) goto fail; -grub_dprintf ("loader" ,"Entry point is 0x%lx.\n" , (unsigned long ) entry); +grub_dprintf (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 (channel,"No multiboot 2 header found.\n" );/* Create the basic tags. */ -grub_dprintf ("loader" ,"Creating multiboot 2 tags\n" ); +grub_dprintf (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 (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 (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 (channel,"Loading module at 0x%x - 0x%x\n" , modaddr, modaddr + modsize);if (grub_file_read (file, (char *) modaddr, modsize) != modsize) {
multiboot_loader.c +7 -5
@@ -31,6 +31,8 @@#include <grub/misc.h> #include <grub/gzio.h> +static const char 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 (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 (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 (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 (channel,"Launching multiboot 1 grub_module() function\n" );grub_module (argc, argv); }#endif if (module_version_status ==2 ) { -grub_dprintf ("multiboot_loader" , +grub_dprintf (channel,"Launching multiboot 2 grub_module2() function\n" );grub_module2 (argc, argv); }
ieee1275/multiboot2.c +5 -3
@@ -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 <grub/machine/kernel.h> #include <grub/machine/loader.h> +static const char 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 *phreturn 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 (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 *phreturn 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 (channel,"Loading segment at 0x%lx - 0x%lx\n" , (unsigned long ) phdr->p_paddr, (unsigned long ) (phdr->p_paddr + phdr->p_memsz));
i386/linux.c +6 -4
@@ -35,6 +35,8 @@static grub_dl_t my_mod; +static const char 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 (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 (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 (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 (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);
i386/pc/multiboot.c +4 -2
@@ -43,6 +43,8 @@#include <grub/gzio.h> #include <grub/env.h> +static const char 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 (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 (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);
i386/efi/linux.c +8 -6
@@ -41,6 +41,8 @@static grub_dl_t my_mod; +static const char 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 (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 (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 (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 (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 (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 (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);
i386/pc/at_keyboard.c +6 -4
@@ -22,6 +22,8 @@#include <grub/misc.h> #include <grub/term.h> +static const char 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 (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 (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 (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 (channel,"Unknown key 0x%x detected\n" , code);if (at_keyboard_status &KEYBOARD_STATUS_CAPS_LOCK ) {
Re: [PATCH] new static const char[] channel (was: modname)
Quoted 6 lines · Felix Zielcke
Am Samstag, den 30.08.2008, 14:42 +0200 schrieb Robert Millan:
Quoted 3 lines
grub_dprintfitself refers to that as "condition". I'd personally prefer "channel" though. What do others think?
Quoted 6 lines
I used now just channel, if others have better suggestions a s/channel/whatever shouldn't be too difficult.
The onlygrub_dprintfcalls that I haven't touched now are infs/reiserfs.c
It uses "reiserfs" and "reiserfs_tree", I wasn't sure if I should merge them or make a channel2="reiserfs_tree"
Or perhaps debug_channel, to make it less ambigous?
Looks fine to me, but please wait a bit to see if others have any opinion on this.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Re: [PATCH] new static const char[] channel (was: modname)
In reply to Felix ZielckeAm Montag, den 01.09.2008, 13:24 +0200 schrieb Felix Zielcke:
Review
Quoted 3 lines
(quoted diff) +0
-2-rw-r--r-- 1 root root 25171 31. Aug 19:39 core.img -rw-r--r-- 1 root root 25153 1. Sep 13:19 core.img
Uhm this was a comparison of apple and oranges and it seems even without my patch
As Robert did the upload to debian experimental I had choosen to update my grub2 with that one, but he's not that bleeding edge like me (whole system Debian sid + experimental)
current upstream SVN without my patch
-rw-r--r-- 1 root root 25153 2. Sep 15:02 /boot/grub/core.img and with it
-rw-r--r-- 1 root root 25220 2. Sep 15:10 /boot/grub/core.img
So it seems it's getting 67 bytes bigger in my case :(
$ gcc -v Using built-in specs. Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.1-9' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-cld --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.3.1 (Debian 4.3.1-9)
Signature · 1 line
Felix Zielcke
[RFC] Re: [PATCH] new static const char[] channel (was: modname)
Am Dienstag, den 02.09.2008, 15:12 +0200 schrieb Felix Zielcke:
Quoted 6 lines
current upstream SVN without my patch
-rw-r--r-- 1 root root 25153 2. Sep 15:02/boot/grub/core.imgand with it
-rw-r--r-- 1 root root 25220 2. Sep 15:10/boot/grub/core.imgSo it seems it's getting 67 bytes bigger in my case :(
As now even talked on IRC GCC seems to be able to optimize string constants already better with directly using them instead of using a `static const char' for them.
Probable because some strings appear in more then one file.
So in terms of code size better use a macro for this, which would be then a pure cosmetical change.
Attached is now my previous patch, changed with a bit Search&Replace, so you all can easily see how it would actually look like.
Signature · 1 line
Felix Zielcke
2008-09-01 Felix Zielcke <[email protected]>
* 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.
scsi.c +7 -5
@@ -28,6 +28,8 @@#include <grub/scsicmd.h> +#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_dreturn 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 ;
ieee1275/ofdisk.c +11 -9
@@ -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 <grub/ieee1275/ieee1275.h> #include <grub/ieee1275/ofdisk.h> +#define DEBUG_CHANNEL = "disk"; +static int grub_ofdisk_iterate (int (*hook) (const char *name)) {
@@ -30,7 +32,7 @@ grub_ofdisk_iterate (int (*hook) (constint 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) (constif (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, grubif (!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, grubstatic 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, grubgrub_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);
ata.c +14 -12
@@ -27,6 +27,8 @@/* XXX: For now this only works on i386. */ #include <grub/cpu/io.h> +#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, instruct 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" );
i386/pc/biosdisk.c +3 -1
@@ -27,6 +27,8 @@#include <grub/err.h> #include <grub/term.h> +#define DEBUG_CHANNEL = "disk"; +static int cd_drive =0 ; static int
@@ -72,7 +74,7 @@ grub_biosdisk_iterate (int (*hook) (consif (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 ; }
raid.c +6 -4
@@ -24,6 +24,8 @@#include <grub/misc.h> #include <grub/raid.h> +#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_dbreak ; } -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 ggrub_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)
efi/efidisk.c +12 -10
@@ -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 <grub/efi/efi.h> #include <grub/efi/disk.h> +#define DEBUG_CHANNEL = "efidisk"; +struct grub_efidisk_data {grub_efi_handle_t handle;
@@ -441,7 +443,7 @@ grub_efidisk_iterate (int (*hook) (constfor (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) (constfor (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) (constfor (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, strstruct 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);
memdisk.c +4 -2
@@ -25,6 +25,8 @@#include <grub/types.h> #include <grub/machine/kernel.h> +#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);
dl.c +8 -6
@@ -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 <grub/env.h> #include <grub/cache.h> +#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_sizeElf_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_sizegrub_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))
sparc64/ieee1275/openfw.c +6 -4
@@ -23,6 +23,8 @@#include <grub/machine/kernel.h> /* Needed ? */ #include <grub/ieee1275/ieee1275.h> +#define DEBUG_CHANNEL = "devalias"; +enum grub_ieee1275_parse_type {GRUB_PARSE_FILENAME ,
@@ -105,7 +107,7 @@ grub_devalias_iterate (int (*hook) (strugrub_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) (struif (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 ;
ieee1275/openfw.c +5 -3
@@ -25,6 +25,8 @@#include <grub/machine/kernel.h> #include <grub/ieee1275/ieee1275.h> +#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) (struif (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; }
elf.c +8 -6
@@ -25,6 +25,8 @@#include <grub/misc.h> #include <grub/mm.h> +#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_eif (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_eif (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);
fs.c +5 -3
@@ -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 <grub/mm.h> #include <grub/term.h> +#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 )
partition.c +5 -3
@@ -20,6 +20,8 @@#include <grub/partition.h> #include <grub/disk.h> +#define DEBUG_CHANNEL = "partition"; +static grub_partition_map_t grub_partition_map_list;void
@@ -103,18 +105,18 @@ grub_partition_iterate (struct grub_diskint 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 ; }
disk.c +9 -7
@@ -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_dchar *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_dif ((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 ;
reiserfs.c +17 -14
@@ -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 *figrub_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_nif (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_ngrub_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_nif (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_ngrub_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);
script.c +8 -6
@@ -22,6 +22,8 @@#include <grub/parser.h> #include <grub/mm.h> +#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_scriptwhile (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_parstruct 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;
lexer.c +10 -8
@@ -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 *yylvaif (! 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 *yylvagrub_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 *yylvaif (! (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 *yylvacase '\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 ; }
i386/pc/play.c +5 -3
@@ -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 noteshort 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)
apple.c +5 -3
@@ -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_tif (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_tif (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),
pc.c +4 -2
@@ -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,
gpt.c +4 -2
@@ -25,6 +25,8 @@#include <grub/pc_partition.h> #include <grub/gpt_partition.h> +#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 dif (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);
powerpc/ieee1275/linux.c +11 -9
@@ -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) {
multiboot2.c +13 -11
@@ -30,6 +30,8 @@#include <grub/misc.h> #include <grub/gzio.h> +#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, igrub_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, igrub_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 aif (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) {
multiboot_loader.c +7 -5
@@ -31,6 +31,8 @@#include <grub/misc.h> #include <grub/gzio.h> +#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); }
ieee1275/multiboot2.c +5 -3
@@ -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 <grub/machine/kernel.h> #include <grub/machine/loader.h> +#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 *phreturn 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 *phreturn 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));
i386/linux.c +6 -4
@@ -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);
i386/pc/multiboot.c +4 -2
@@ -43,6 +43,8 @@#include <grub/gzio.h> #include <grub/env.h> +#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);
i386/efi/linux.c +8 -6
@@ -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);
i386/pc/at_keyboard.c +6 -4
@@ -22,6 +22,8 @@#include <grub/misc.h> #include <grub/term.h> +#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 ) {
Re: [RFC] Re: [PATCH] new static const char[] channel (was: modname)
Quoted 14 lines · Felix Zielcke
Am Dienstag, den 02.09.2008, 15:12 +0200 schrieb Felix Zielcke:
Quoted 6 lines
current upstream SVN without my patch
-rw-r--r-- 1 root root 25153 2. Sep 15:02/boot/grub/core.imgand with it
-rw-r--r-- 1 root root 25220 2. Sep 15:10/boot/grub/core.imgSo it seems it's getting 67 bytes bigger in my case :(
As now even talked on IRC GCC seems to be able to optimize string constants already better with directly using them instead of using a `static const char' for them.
Probable because some strings appear in more then one file.
Quoted 5 lines
So in terms of code size better use a macro for this, which would be then a pure cosmetical change.
Attached is now my previous patch, changed with a bit Search&Replace, so you all can easily see how it would actually look like.
I don't think there's any gain in this. Initially, I thought it'd be an improvement size-wise, but now it's only an added level of complexity when reading the code, in it just adds confusion AFAICS.
Seeing that size is not an issue, I think the current use scheme of grub_dprintf is fine already.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."