From 8c8cc20511999e17718a27fb0a3691ecfc871cf5 Mon Sep 17 00:00:00 2001 From: jeroen Date: Sun, 14 Mar 2004 17:48:25 +0000 Subject: [PATCH] 2004-03-14 Jeroen Dekkers * Makefile.in: Update copyright. * genmodsrc.sh: Likewise. * gensymlist.sh: Likewise. * term/i386/pc/vga.c: Indent correctly. * util/i386/pc/pupa-mkimage.c (usage): Use PACKAGE_BUGREPORT as bugreporting address. * util/i386/pc/pupa-setup.c (usage): Likewise, (main): Call pupa_ext2_init and pupa_ext2_fini. * fs/fat.c (log2): Renamed to ... (fat_log2): ... this. All callers changed. * kern/misc.c (memcpy): Alias to pupa_memmove. * loader/i386/pc/multiboot.c (pupa_rescue_cmd_multiboot): Fix lvalue cast. * util/console.c (pupa_ncurses_fini): Return 0. * util/i386/pc/biosdisk.c (pupa_util_biosdisk_open)[__linux__]: Move fail label here. [__GNU__]: Don't warn when using stat. (open_device)[!__linux__]: Check if FD < 0 instead of !FD. (pupa_util_biosdisk_get_pupa_dev)[__GNU__]: Change type of N to long int. Use strtol instead of strtoul. --- ChangeLog | 27 ++++++ Makefile.in | 3 +- fs/fat.c | 9 +- genmodsrc.sh | 2 +- gensymlist.sh | 2 +- kern/misc.c | 5 +- loader/i386/pc/multiboot.c | 4 +- term/i386/pc/vga.c | 180 ++++++++++++++++++------------------ util/console.c | 1 + util/i386/pc/biosdisk.c | 15 +-- util/i386/pc/grub-mkimage.c | 6 +- util/i386/pc/grub-setup.c | 10 +- 12 files changed, 149 insertions(+), 115 deletions(-) diff --git a/ChangeLog b/ChangeLog index a76878006..e9fc249ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2004-03-14 Jeroen Dekkers + + * Makefile.in: Update copyright. + * genmodsrc.sh: Likewise. + * gensymlist.sh: Likewise. + * term/i386/pc/vga.c: Indent correctly. + + * util/i386/pc/pupa-mkimage.c (usage): Use PACKAGE_BUGREPORT as + bugreporting address. + * util/i386/pc/pupa-setup.c (usage): Likewise, + (main): Call pupa_ext2_init and pupa_ext2_fini. + + * fs/fat.c (log2): Renamed to ... + (fat_log2): ... this. + All callers changed. + * kern/misc.c (memcpy): Alias to pupa_memmove. + * loader/i386/pc/multiboot.c (pupa_rescue_cmd_multiboot): Fix + lvalue cast. + * util/console.c (pupa_ncurses_fini): Return 0. + + * util/i386/pc/biosdisk.c (pupa_util_biosdisk_open)[__linux__]: + Move fail label here. + [__GNU__]: Don't warn when using stat. + (open_device)[!__linux__]: Check if FD < 0 instead of !FD. + (pupa_util_biosdisk_get_pupa_dev)[__GNU__]: Change type of N to + long int. Use strtol instead of strtoul. + 2004-03-14 Marco Gerards * commands/boot.c: New file. diff --git a/Makefile.in b/Makefile.in index f1451cac7..7e9a14a36 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,7 +1,6 @@ # -*- makefile -*- # -# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc. -# Copyright (C) 2002 Yoshinori K. Okuji +# Copyright (C) 1994,95,96,97,98,99,2000,01,02,04 Free Software Foundation, Inc. # # This Makefile.in is free software; the author # gives unlimited permission to copy and/or distribute it, diff --git a/fs/fat.c b/fs/fat.c index 9ee62b514..bb1a48cb9 100644 --- a/fs/fat.c +++ b/fs/fat.c @@ -1,7 +1,7 @@ /* fat.c - FAT filesystem */ /* * PUPA -- Preliminary Universal Programming Architecture for GRUB - * Copyright (C) 2000,2001,2002,2003 Free Software Foundation, Inc. + * Copyright (C) 2000,2001,2002,2003,2004 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -130,7 +130,7 @@ static pupa_dl_t my_mod; #endif static int -log2 (unsigned x) +fat_log2 (unsigned x) { int i; @@ -165,12 +165,13 @@ pupa_fat_mount (pupa_disk_t disk) goto fail; /* Get the sizes of logical sectors and clusters. */ - data->logical_sector_bits = log2 (pupa_le_to_cpu16 (bpb.bytes_per_sector)); + data->logical_sector_bits = + fat_log2 (pupa_le_to_cpu16 (bpb.bytes_per_sector)); if (data->logical_sector_bits < PUPA_DISK_SECTOR_BITS) goto fail; data->logical_sector_bits -= PUPA_DISK_SECTOR_BITS; - data->cluster_bits = log2 (bpb.sectors_per_cluster); + data->cluster_bits = fat_log2 (bpb.sectors_per_cluster); if (data->cluster_bits < 0) goto fail; data->cluster_bits += data->logical_sector_bits; diff --git a/genmodsrc.sh b/genmodsrc.sh index 5933170a1..8bff6dd46 100644 --- a/genmodsrc.sh +++ b/genmodsrc.sh @@ -20,7 +20,7 @@ cat < + * Copyright (C) 2002 Free Software Foundation, Inc. * * PUPA is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gensymlist.sh b/gensymlist.sh index 003dc22be..6ac3996a2 100644 --- a/gensymlist.sh +++ b/gensymlist.sh @@ -15,7 +15,7 @@ cat < + * Copyright (C) 2002 Free Software Foundation, Inc. * * PUPA is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/kern/misc.c b/kern/misc.c index a47adac83..3e5c2b509 100644 --- a/kern/misc.c +++ b/kern/misc.c @@ -1,7 +1,7 @@ /* misc.c - definitions of misc functions */ /* * PUPA -- Preliminary Universal Programming Architecture for GRUB - * Copyright (C) 1999,2000,2001,2002,2003 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * * PUPA is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,6 +45,9 @@ pupa_memmove (void *dest, const void *src, pupa_size_t n) return dest; } +/* GCC emits references to memcpy() for struct copies etc. */ +void *memcpy (void *dest, const void *src, pupa_size_t n) + __attribute__ ((alias ("pupa_memmove"))); char * pupa_strcpy (char *dest, const char *src) diff --git a/loader/i386/pc/multiboot.c b/loader/i386/pc/multiboot.c index 7757affe8..35398c3b3 100644 --- a/loader/i386/pc/multiboot.c +++ b/loader/i386/pc/multiboot.c @@ -1,7 +1,7 @@ /* multiboot.c - boot a multiboot OS image. */ /* * PUPA -- Preliminary Universal Programming Architecture for GRUB - * Copyright (C) 2003 Free Software Foundation, Inc. + * Copyright (C) 2003, 2004 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -119,7 +119,7 @@ pupa_rescue_cmd_multiboot (int argc, char *argv[]) be at least 12 bytes and aligned on a 4-byte boundary. */ for (header = (struct pupa_multiboot_header *) buffer; ((char *) header <= buffer + len - 12) || (header = 0); - (char *)header += 4) + header = (struct pupa_multiboot_header *) ((char *)header + 4)) { if (header->magic == PUPA_MB_MAGIC && !(header->magic + header->flags + header->checksum)) diff --git a/term/i386/pc/vga.c b/term/i386/pc/vga.c index ca750c6af..b715f2bdf 100644 --- a/term/i386/pc/vga.c +++ b/term/i386/pc/vga.c @@ -1,6 +1,6 @@ /* * PUPA -- Preliminary Universal Programming Architecture for GRUB - * Copyright (C) 2000,2001,2002,2003 Free Software Foundation, Inc. + * Copyright (C) 2000,2001,2002,2003,2004 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -407,108 +407,108 @@ pupa_vga_putchar (pupa_uint32_t c) #endif } - static pupa_uint16_t - pupa_vga_getxy (void) - { - return ((xpos << 8) | ypos); - } +static pupa_uint16_t +pupa_vga_getxy (void) +{ + return ((xpos << 8) | ypos); +} - static void - pupa_vga_gotoxy (pupa_uint8_t x, pupa_uint8_t y) - { - if (x >= TEXT_WIDTH || y >= TEXT_HEIGHT) - { - pupa_error (PUPA_ERR_OUT_OF_RANGE, "invalid point (%u,%u)", - (unsigned) x, (unsigned) y); - return; - } +static void +pupa_vga_gotoxy (pupa_uint8_t x, pupa_uint8_t y) +{ + if (x >= TEXT_WIDTH || y >= TEXT_HEIGHT) + { + pupa_error (PUPA_ERR_OUT_OF_RANGE, "invalid point (%u,%u)", + (unsigned) x, (unsigned) y); + return; + } - if (cursor_state) - write_char (); + if (cursor_state) + write_char (); - xpos = x; - ypos = y; + xpos = x; + ypos = y; - if (cursor_state) - write_cursor (); - } + if (cursor_state) + write_cursor (); +} - static void - pupa_vga_cls (void) - { - unsigned i; +static void +pupa_vga_cls (void) +{ + unsigned i; - for (i = 0; i < TEXT_WIDTH * TEXT_HEIGHT; i++) - { - text_buf[i].code = ' '; - text_buf[i].fg_color = 0; - text_buf[i].bg_color = 0; - text_buf[i].width = 0; - text_buf[i].index = 0; - } + for (i = 0; i < TEXT_WIDTH * TEXT_HEIGHT; i++) + { + text_buf[i].code = ' '; + text_buf[i].fg_color = 0; + text_buf[i].bg_color = 0; + text_buf[i].width = 0; + text_buf[i].index = 0; + } - pupa_memset (VGA_MEM, 0, VGA_WIDTH * VGA_HEIGHT / 8); + pupa_memset (VGA_MEM, 0, VGA_WIDTH * VGA_HEIGHT / 8); - xpos = ypos = 0; - } + xpos = ypos = 0; +} - static void - pupa_vga_setcolorstate (pupa_term_color_state state) - { - switch (state) - { - case PUPA_TERM_COLOR_STANDARD: - case PUPA_TERM_COLOR_NORMAL: - fg_color = DEFAULT_FG_COLOR; - bg_color = DEFAULT_BG_COLOR; - break; - case PUPA_TERM_COLOR_HIGHLIGHT: - fg_color = DEFAULT_BG_COLOR; - bg_color = DEFAULT_FG_COLOR; - break; - default: - break; - } - } +static void +pupa_vga_setcolorstate (pupa_term_color_state state) +{ + switch (state) + { + case PUPA_TERM_COLOR_STANDARD: + case PUPA_TERM_COLOR_NORMAL: + fg_color = DEFAULT_FG_COLOR; + bg_color = DEFAULT_BG_COLOR; + break; + case PUPA_TERM_COLOR_HIGHLIGHT: + fg_color = DEFAULT_BG_COLOR; + bg_color = DEFAULT_FG_COLOR; + break; + default: + break; + } +} - static void - pupa_vga_setcolor (pupa_uint8_t normal_color __attribute__ ((unused)), - pupa_uint8_t highlight_color __attribute__ ((unused))) - { - /* FIXME */ - } +static void +pupa_vga_setcolor (pupa_uint8_t normal_color __attribute__ ((unused)), + pupa_uint8_t highlight_color __attribute__ ((unused))) +{ + /* FIXME */ +} - static void - pupa_vga_setcursor (int on) - { - if (cursor_state != on) - { - if (cursor_state) - write_char (); - else - write_cursor (); +static void +pupa_vga_setcursor (int on) +{ + if (cursor_state != on) + { + if (cursor_state) + write_char (); + else + write_cursor (); - cursor_state = on; - } - } + cursor_state = on; + } +} - static struct pupa_term pupa_vga_term = - { - .name = "vga", - .init = pupa_vga_init, - .fini = pupa_vga_fini, - .putchar = pupa_vga_putchar, - .checkkey = pupa_console_checkkey, - .getkey = pupa_console_getkey, - .getxy = pupa_vga_getxy, - .gotoxy = pupa_vga_gotoxy, - .cls = pupa_vga_cls, - .setcolorstate = pupa_vga_setcolorstate, - .setcolor = pupa_vga_setcolor, - .setcursor = pupa_vga_setcursor, - .flags = 0, - .next = 0 - }; +static struct pupa_term pupa_vga_term = + { + .name = "vga", + .init = pupa_vga_init, + .fini = pupa_vga_fini, + .putchar = pupa_vga_putchar, + .checkkey = pupa_console_checkkey, + .getkey = pupa_console_getkey, + .getxy = pupa_vga_getxy, + .gotoxy = pupa_vga_gotoxy, + .cls = pupa_vga_cls, + .setcolorstate = pupa_vga_setcolorstate, + .setcolor = pupa_vga_setcolor, + .setcursor = pupa_vga_setcursor, + .flags = 0, + .next = 0 + }; static pupa_err_t debug_command (struct pupa_arg_list *state __attribute__ ((unused)), diff --git a/util/console.c b/util/console.c index b75238faa..e139d7d6d 100644 --- a/util/console.c +++ b/util/console.c @@ -177,6 +177,7 @@ static pupa_err_t pupa_ncurses_fini (void) { endwin (); + return 0; } diff --git a/util/i386/pc/biosdisk.c b/util/i386/pc/biosdisk.c index 1b33039d1..76a879b5a 100644 --- a/util/i386/pc/biosdisk.c +++ b/util/i386/pc/biosdisk.c @@ -1,7 +1,7 @@ /* biosdisk.c - emulate biosdisk */ /* * PUPA -- Preliminary Universal Programming Architecture for GRUB - * Copyright (C) 1999,2000,2001,2002,2003 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * * PUPA is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -190,11 +190,12 @@ pupa_util_biosdisk_open (const char *name, pupa_disk_t disk) return PUPA_ERR_NONE; } -#else -# warning "No special routine to get the size of a block device is implemented for your OS. This is not possibly fatal." -#endif fail: + /* In GNU/Hurd, stat() will return the right size. */ +#elif !defined (__GNU__) +# warning "No special routine to get the size of a block device is implemented for your OS. This is not possibly fatal." +#endif if (stat (map[drive], &st) < 0) return pupa_error (PUPA_ERR_BAD_DEVICE, "cannot stat `%s'", map[drive]); @@ -325,7 +326,7 @@ open_device (const pupa_disk_t disk, unsigned long sector, int flags) } #else /* ! __linux__ */ fd = open (map[disk->id], flags); - if (! fd) + if (fd < 0) { pupa_error (PUPA_ERR_BAD_DEVICE, "cannot open `%s'", map[disk->id]); return -1; @@ -815,11 +816,11 @@ pupa_util_biosdisk_get_pupa_dev (const char *os_dev) p = strrchr (os_dev, 's'); if (p) { - unsigned long n; + long int n; char *q; p++; - n = strtoul (p, &q, 10); + n = strtol (p, &q, 10); if (p != q && n != LONG_MIN && n != LONG_MAX) { dos_part = (int) n; diff --git a/util/i386/pc/grub-mkimage.c b/util/i386/pc/grub-mkimage.c index d38c5fcad..be62a96da 100644 --- a/util/i386/pc/grub-mkimage.c +++ b/util/i386/pc/grub-mkimage.c @@ -1,7 +1,7 @@ /* pupa-mkimage.c - make a bootable image */ /* * PUPA -- Preliminary Universal Programming Architecture for GRUB - * Copyright (C) 2002,2003 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2004 Free Software Foundation, Inc. * * PUPA is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -192,8 +192,8 @@ Make a bootable image of PUPA.\n\ -V, --version print version information and exit\n\ -v, --verbose print verbose messages\n\ \n\ -Report bugs to .\n\ -", PUPA_DATADIR); +Report bugs to <%s>.\n\ +", PUPA_DATADIR, PACKAGE_BUGREPORT); exit (status); } diff --git a/util/i386/pc/grub-setup.c b/util/i386/pc/grub-setup.c index de8202579..587472ca6 100644 --- a/util/i386/pc/grub-setup.c +++ b/util/i386/pc/grub-setup.c @@ -1,7 +1,7 @@ /* pupa-setup.c - make PUPA usable */ /* * PUPA -- Preliminary Universal Programming Architecture for GRUB - * Copyright (C) 1999,2000,2001,2002,2003 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * * PUPA is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -470,10 +470,10 @@ DEVICE must be a PUPA device (e.g. ``(hd0,0)'').\n\ -V, --version print version information and exit\n\ -v, --verbose print verbose messages\n\ \n\ -Report bugs to .\n\ +Report bugs to <%s>.\n\ ", - DEFAULT_BOOT_FILE, DEFAULT_CORE_FILE, - DEFAULT_DIRECTORY, DEFAULT_DEVICE_MAP); + DEFAULT_BOOT_FILE, DEFAULT_CORE_FILE, DEFAULT_DIRECTORY, + DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT); exit (status); } @@ -594,6 +594,7 @@ main (int argc, char *argv[]) /* Initialize filesystems. */ pupa_fat_init (); + pupa_ext2_init (); if (root_dev) { @@ -625,6 +626,7 @@ main (int argc, char *argv[]) root_dev, dest_dev); /* Free resources. */ + pupa_ext2_fini (); pupa_fat_fini (); pupa_util_biosdisk_fini ();