2003-11-16 Jeroen Dekkers * conf/i386-pc.rmk (pkgdata_MODULES): Add _multiboot.mod. (_multiboot_mod_SOURCES): New variable. (_multiboot_mod_CFLAGS): Likewise. * loader/i386/pc/multiboot.c: New file. * include/pupa/i386/pc/multiboot.h: Likewise. * kern/i386/pc/startup.S: Include pupa/machine/multiboot.h. (pupa_multiboot_real_boot): New function. * include/pupa/i386/pc/loader.h: Include pupa/machine/multiboot.h. (pupa_multiboot_real_boot): New prototype. (pupa_rescue_cmd_multiboot): Likewise (pupa_rescue_cmd_module): Likewise. * kern/loader.c (pupa_loader_set): Continue when pupa_loader_unload_func() fails. (pupa_loader_unset): New function. * include/pupa/loader.h (pupa_loader_unset): New prototype. * kern/misc.c (pupa_stpcpy): New function. * include/pupa/misc.h (pupa_stpcpy): New prototype. 2003-11-12 Marco Gerards * disk/i386/pc/biosdisk.c (pupa_biosdisk_open): Correctly check for available extensions. * include/pupa/i386/pc/time.h: New file. * kern/disk.c: Include . (PUPA_CACHE_TIMEOUT): New macro. (pupa_last_time): New variable. (pupa_disk_open): Flush the cache when there was a timeout. (pupa_disk_close): Reset the timer. * kern/i386/pc/startup.S (pupa_get_rtc): Renamed from pupa_currticks. * util/misc.c: Include (pupa_get_rtc): New function. 2003-11-09 Jeroen Dekkers * fs/ext2.c (struct pupa_ext2_inode): Declare struct datablocks as blocks. (pupa_ext2_get_file_block): Use blocks member. * fs/ext2.c (pupa_ext2_read_file): Only set skipfirst for the first block. Return -1 instead of pupa_errno on error. 2003-10-27 Marco Gerards * README: In the pupa-mkimage example use _chain instead of chain and ext2 instead of fat. * TODO: Replace ext2fs with jfs as an example. Add an item for adding journal playback for ext2fs. * conf/i386-pc.rmk (pupa_setup_SOURCES): Added fs/ext2.c. (pkgdata_MODULES): Added ext2.mod. (ext2_mod_SOURCES): New variable. (ext2_mod_CFLAGS): Likewise. * include/pupa/err.h (pupa_err_t): Added PUPA_ERR_SYMLINK_LOOP. * include/pupa/misc.h (pupa_strncpy): New prototype. (pupa_strcat): Likewise. (pupa_strncmp): Likewise. * kern/misc.c (pupa_strcat): Enable function. (pupa_strncpy): New function. (pupa_strncmp): Likewise. * fs/ext2.c: New file. * kern/disk.c (pupa_disk_read): Set pupa_errno to PUPA_ERR_NONE when the read failed before retrying. * util/i386/pc/biosdisk.c (_LARGEFILE_SOURCE): Removed. (_FILE_OFFSET_BITS): Likewise. * configure.ac: Added AC_SYS_LARGEFILE. 2003-09-25 Yoshinori K. Okuji * genmk.rb (PModule#rule): Make sure to get only symbol names from the output of nm. Reported by Robert Millan . 2003-09-25 Yoshinori K. Okuji I forgot to check in these changes for a long time. This adds incomplete support for VGA console, and this is still very buggy. Also, a lot of consideration is required for I18N, UNICODE, and VGA font issues. Therefore, assume that this is such that "better than nothing". * font/manager.c: New file. * include/pupa/font.h: Likewise. * include/pupa/i386/pc/vga.h: Likewise. * term/i386/pc/vga.c: Likewise. * util/unifont2pff.rb: Likewise. * conf/i386-pc.rmk (kernel_img_HEADERS): Added machine/vga.h. (pkgdata_MODULES): Added vga.mod and font.mod. (vga_mod_SOURCES): New variables. (vga_mod_CFLAGS): Likewise. (font_mod_SOURCES): Likewise. (font_mod_CFLAGS): Likewise. * include/pupa/err.h (PUPA_ERR_BAD_FONT): New constant. * include/pupa/term.h: Include pupa/err.h. (struct pupa_term): Added init and fini. Changed the argument of putchar to pupa_uint32_t. * include/pupa/i386/pc/console.h: Include pupa/symbol.h. (pupa_console_real_putchar): New prototype. (pupa_console_putchar): Removed. (pupa_console_checkkey): Exported. (pupa_console_getkey): Likewise. * kern/misc.c (pupa_vsprintf): Add support for UNICODE characters. * kern/term.c (pupa_term_set_current): Rewritten. (pupa_putchar): Likewise. (pupa_putcode): New function. * kern/i386/pc/startup.S (pupa_console_putchar): Renamed to ... (pupa_console_real_putchar): ... this. (pupa_vga_set_mode): New function. (pupa_vga_get_font): Likewise. * normal/command.c: Include pupa/term.h. (terminal_command): New function. (pupa_command_init): Register the command "terminal". * normal/menu.c (DISP_LEFT): Changed to a UNICODE value. (DISP_UP): Likewise. (DISP_RIGHT): Likewise. (DISP_DOWN): Likewise. (DISP_HLINE): Likewise. (DISP_VLINE): Likewise. (DISP_UL): Likewise. (DISP_UR): Likewise. (DISP_LL): Likewise. (DISP_LR): Likewise. * term/i386/pc/console.c (pupa_console_putchar): New function. 2003-02-08 NIIBE Yutaka * util/resolve.c (pupa_util_resolve_dependencies): BUG FIX. Reverse the path_list. * include/pupa/normal.h: Export pupa_register_command and pupa_unregister_command. * hello/hello.c (pupa_cmd_hello): New module. * conf/i386-pc.rmk: Added hello.mod. 2003-01-31 Yoshinori K. Okuji * kern/i386/pc/lzo1x.S: New file. * util/i386/pc/pupa-mkimage.c: Include lzo1x.h. (compress_kernel): New variable. (generate_image): Heavily modified to support compressing a large part of the core image. * util/misc.c (pupa_util_read_image): Fix a file descriptor leak. (pupa_util_load_image): New function. * kern/i386/pc/startup.S: Include pupa/machine/kernel.h. (pupa_compressed_size): New variable. (codestart): Enable Gate A20 here. Decompress the compressed part of the core image. Rearrange the code to put functions and variables which are required for initialization in the non-compressed part. Include lzo1x.S. * kern/i386/pc/init.c (pupa_machine_init): Don't enable Gate A20 here. * include/pupa/util/misc.h (pupa_util_write_image): Declared. * include/pupa/i386/pc/kernel.h (PUPA_KERNEL_MACHINE_COMPRESSED_SIZE): New macro. (PUPA_KERNEL_MACHINE_INSTALL_DOS_PART): Increased by 4. (PUPA_KERNEL_MACHINE_INSTALL_BSD_PART): Likewise. (PUPA_KERNEL_MACHINE_PREFIX): Likewise. (PUPA_KERNEL_MACHINE_RAW_SIZE): New macro. * conf/i386-pc.rmk (pupa_mkimage_LDFLAGS): New variable. * genmk.rb (Image#rule): Put LDFLAGS at the end of a line. (Utility#rule): Likewise. * configure.ac: Check if LZO is available. 2003-01-20 Yoshinori K. Okuji * include/pupa/normal.h: New file. * include/pupa/setjmp.h: Likewise. * include/pupa/i386/setjmp.h: Likewise. * normal/cmdline.c: Likewise. * normal/command.c: Likewise. * normal/main.c: Likewise. * normal/menu.c: Likewise. * normal/i386/setjmp.S: Likewise. * loader/i386/pc/linux.c (pupa_rescue_cmd_linux): Made global. (pupa_rescue_cmd_initrd): Likewise. * loader/i386/pc/chainloader.c (pupa_rescue_cmd_chainloader): Likewise. * kern/i386/pc/startup.S (translation_table): New variable. (translate_keycode): New function. (pupa_console_getkey): Call translate_keycode. * kern/rescue.c (attempt_normal_mode): New function. (pupa_enter_rescue_mode): Attempt to execute the normal mode. If it failed, print a message. * kern/mm.c (pupa_real_malloc): Print more information when a free magic is broken. (pupa_free): If the first free header is not free actually, set it to P. * kern/main.c (pupa_load_normal_mode): Just load the module "normal". (pupa_main): Don't print the message "Entering into rescue mode..." here. * include/pupa/i386/pc/loader.h (pupa_rescue_cmd_initrd): Declared. (pupa_rescue_cmd_initrd): Likewise. (pupa_rescue_cmd_initrd): Likewise. * include/pupa/symbol.h (FUNCTION): Specify the type. (VARIABLE): Likewise. * include/pupa/err.h (pupa_err_t): Added PUPA_ERR_UNKNOWN_COMMAND. * include/pupa/dl.h (pupa_dl_set_prefix): Exported. (pupa_dl_get_prefix): Likewise. * conf/i386-pc.rmk (pkgdata_MODULES): Added normal.mod. Added _chain.mod and _linux.mod instead of chain.mod and linux.mod. (chain_mod_SOURCES): Renamed to ... (_chain_mod_SOURCES): ... this. (chain_mod_CFLAGS): Renamed to ... (_chain_mod_CFLAGS): ... this. (linux_mod_SOURCES): Renamed to ... (_linux_mod_SOURCES): ... this. (linux_mod_CFLAGS): Renamed to ... (_linux_mod_CFLAGS): ... this. (normal_mod_SOURCES): New variable. (normal_mod_CFLAGS): Likewise. (normal_mod_ASFLAGS): Likewise. 2003-01-18 Yoshinori K. Okuji * kern/rescue.c (pupa_rescue_cmd_rmmod): Call pupa_dl_unload, if possible. * kern/dl.c (pupa_dl_ref): Refer dependending modules recursively. (pupa_dl_unref): Unrefer depending modules recursively. Don't call pupa_dl_unload implicitly, because PUPA can crash if a module is unloaded before one depending on that module is unloaded. (pupa_dl_unload): Unload depending modules explicitly, if possible. 2003-01-17 Yoshinori K. Okuji * include/pupa/i386/pc/linux.h: New file. * loader/i386/pc/linux.c: Likewise. * loader/i386/pc/chainloader.c (pupa_chainloader_boot_sector): Removed. (pupa_chainloader_unload): Return PUPA_ERR_NONE. (pupa_rescue_cmd_chainloader): Read the image to 0x7C00 instead of PUPA_CHAINLOADER_BOOT_SECTOR. * kern/i386/pc/startup.S: Include pupa/machine/linux.h. (pupa_linux_prot_size): New variable. (pupa_linux_tmp_addr): Likewise. (pupa_linux_real_addr): Likewise. (pupa_linux_boot_zimage): New function. (pupa_linux_boot_bzimage): Likewise. * kern/i386/pc/init.c (struct mem_region): New structure. (MAX_REGIONS): New macro. (mem_regions): New variable. (num_regions): Likewise. (pupa_os_area_addr): Likewise. (pupa_os_area_size): Likewise. (pupa_lower_mem): Likewise. (pupa_upper_mem): Likewise. (add_mem_region): New function. (compact_mem_regions): Likewise. (pupa_machine_init): Set PUPA_LOWER_MEM and PUPA_UPPER_MEM to the size of the conventional memory and that of so-called upper memory (before the first memory hole). Instead of adding each found region to free memory, use add_mem_region and add them after removing overlaps. Also, add only 1/4 of the upper memory to free memory. The rest is used for loading OS images. Maybe this is ad hoc, but this makes it much easier to relocate OS images when booting. * kern/rescue.c (pupa_rescue_cmd_module): Removed. (pupa_enter_rescue_mode): Don't register initrd and module. * kern/mm.c: Include pupa/dl.h. * kern/main.c: Include pupa/file.h and pupa/device.h. * kern/loader.c (pupa_loader_load_module_func): Removed. (pupa_loader_load_module): Likewise. * kern/dl.c (pupa_dl_load): Use the suffix ``.mod'' instead of ``.o''. * include/pupa/i386/pc/loader.h (pupa_linux_prot_size): Declared. (pupa_linux_tmp_addr): Likewise. (pupa_linux_real_addr): Likewise. (pupa_linux_boot_zimage): Likewise. (pupa_linux_boot_bzimage): Likewise. * include/pupa/i386/pc/init.h (pupa_lower_mem): Declared. (pupa_upper_mem): Likewise. (pupa_gate_a20): Don't export, because turning off Gate A20 in a module is too dangerous. * include/pupa/loader.h (pupa_os_area_addr): Declared. (pupa_os_area_size): Likewise. (pupa_loader_set): Remove the first argument. Loader doesn't manage modules or initrd any longer. (pupa_loader_load_module): Removed. * conf/i386-pc.rmk (pkgdata_MODULES): Added linux.mod. (linux_mod_SOURCES): New variable. (linux_mod_CFLAGS): Likewise. 2003-01-07 Yoshinori K. Okuji * util/i386/pc/pupa-setup.c (setup): Convert the endianness of the length of a blocklist correctly. * util/i386/pc/biosdisk.c (pupa_util_biosdisk_open) [__linux__]: Use ioctl only if the OS file is a block device. (pupa_util_biosdisk_open): Don't use ST.ST_BLOCKS, because it is not very useful for normal files. * kern/main.c (pupa_set_root_dev): New function. (pupa_load_normal_mode): Likewise. (pupa_main): Call those above. * include/pupa/types.h (pupa_swap_bytes16): Cast the result to pupa_uint16_t. * include/pupa/kernel.h (pupa_enter_normal_mode): Removed. 2003-01-06 Yoshinori K. Okuji * util/i386/pc/pupa-setup.c: Include pupa/machine/kernel.h. (setup): Configure the installed partition information and the dl prefix. * loader/i386/pc/chainloader.c (my_mod): New variable. (pupa_chainloader_unload): New function. (pupa_rescue_cmd_chainloader): Refer itself. (PUPA_MOD_INIT): Save its own module in MY_MOD. * kern/i386/pc/startup.S (install_partition): Removed. (version_string): Likewise. (config_file): Likewise. (pupa_install_dos_part): New variable. (pupa_install_bsd_part): Likewise. (pupa_prefix): Likewise. (pupa_chainloader_real_boot): Call pupa_dl_unload_all. * kern/i386/pc/init.c: Include pupa/machine/kernel.h, pupa/dl.h and pupa/misc.h. (make_install_device): New function. (pupa_machine_init): Set the dl prefix. * kern/rescue.c: Include pupa/rescue.h and pupa/dl.h. (buf): Renamed to ... (linebuf): ... this. (pupa_rescue_cmd_prefix): New function. (pupa_rescue_cmd_insmod): Likewise. (pupa_rescue_cmd_rmmod): Likewise. (pupa_rescue_cmd_lsmod): Likewise. (pupa_enter_rescue_mode): Register new commands: prefix, insmod, rmmod and lsmod. * kern/mm.c (pupa_memalign): If failed even after invalidating disk caches, unload unneeded modules and retry. * kern/misc.c (pupa_memmove): New function. (pupa_memcpy): Removed. (pupa_strcpy): New function. (pupa_itoa): Made static. * kern/dl.c (pupa_dl_iterate): New function. (pupa_dl_ref): Likewise. (pupa_dl_unref): Likewise. (pupa_dl_unload): Return if succeeded or not. (pupa_dl_unload_unneeded): New function. (pupa_dl_unload_all): Likewise. (pupa_dl_init): Renamed to ... (pupa_dl_set_prefix): ... this. (pupa_dl_get_prefix): New function. * include/pupa/i386/pc/kernel.h: Include pupa/types.h. (PUPA_KERNEL_MACHINE_INSTALL_DOS_PART): New macro. (PUPA_KERNEL_MACHINE_INSTALL_BSD_PART): Likewise. (PUPA_KERNEL_MACHINE_PREFIX): Likewise. (pupa_install_dos_part): Declared. (pupa_install_bsd_part): Likewise. (pupa_prefix): Likewise. (pupa_boot_drive): Likewise. * include/pupa/types.h: Fix a typo. * include/pupa/misc.h (pupa_memcpy): New macro. Just an alias to pupa_memmove. (pupa_memmove): Declared. (pupa_strcpy): Likewise. * include/pupa/dl.h (PUPA_MOD_INIT): Change the prototype. Now pupa_mod_init takes one argument, its own module. (pupa_dl_unload_unneeded): Declared. (pupa_dl_unload_all): Likewise. (pupa_dl_ref): Likewise. (pupa_dl_unref): Likewise. (pupa_dl_iterate): Likewise. (pupa_dl_init): Renamed to ... (pupa_dl_set_prefix): ... this. (pupa_dl_get_prefix): Declared. * fs/fat.c [!PUPA_UTIL] (my_mod): New variable. (pupa_fat_dir) [!PUPA_UTIL]: Prevent the fat module from being unloaded. (pupa_fat_open) [!PUPA_UTIL]: Refer itself if succeeded. (pupa_fat_close) [!PUPA_UTIL]: Unrefer itself. * configure.ac (tmp_CFLAGS): Added -Wshadow, -Wpointer-arith, -Wmissing-prototypes, -Wundef and -Wstrict-prototypes. 2003-01-03 Yoshinori K. Okuji * util/i386/pc/pupa-setup.c (setup): Define the internal function find_first_partition_start at the top level, because GCC 3.0.x cannot compile internal functions in deeper scopes correctly. (find_root_device): Use lstat instead of stat. Don't follow symbolic links. Fix the path-constructing code. * util/i386/pc/biosdisk.c [__linux__] (BLKFLSBUF): New macro. (pupa_util_biosdisk_open) [__linux__]: Get the size of a device by a BLKGETSIZE ioctl first, because block devices don't fill the member st_mode of the structure stat on Linux. [__linux__] (linux_find_partition): Use a temporary buffer REAL_DEV for the working space. Copy it to DEV before returning. (open_device) [__linux__]: Call ioctl with BLKFLSBUF to make the buffer cache consistent. (get_os_disk) [__linux__]: Use the length 5 instead of 4 for strncmp. The previous value was merely wrong. (pupa_util_biosdisk_get_pupa_dev): Use stat instead of lstat. * fs/fat.c (pupa_fat_read_data): Shift 4 instead of 12 when the FAT size is 12. The previous value was merely wrong. * kern/main.c (pupa_main): Don't split the starting message from newlines. * kern/term.c (pupa_putchar): Put CR after LF instead of before LF, because BIOS goes crazy about character attributes in this case. 2003-01-03 Yoshinori K. Okuji * include/i386/pc/util/biosdisk.h: New file. * util/i386/pc/biosdisk.c: Likewise. * util/i386/pc/pupa-setup.c: Likewise. * Makefile.in (INCLUDE_DISTFILES): Added include/pupa/i386/pc/util/biosdisk.h. (UTIL_DISTFILES): Added biosdisk.c and pupa-setup.c under the directory util/i386/pc. (install-local): Added a rule for sbin_UTILITIES. (uninstall): Likewise. * util/i386/pc/pupa-mkimage.c (usage): Fix a typo in the doc. * util/misc.c (xrealloc): New function. (pupa_malloc): Likewise. (pupa_free): Likewise. (pupa_realloc): Likewise. (pupa_stop): Likewise. (pupa_putchar): Likewise. * kern/disk.c (pupa_disk_read): Prevent L from underflowing. * include/pupa/util/misc.h (xrealloc): Declared. * include/pupa/i386/pc/boot.h (PUPA_BOOT_MACHINE_BPB_START): New macro. (PUPA_BOOT_MACHINE_BPBEND): Renamed to ... (PUPA_BOOT_MACHINE_BPB_END): ... this. * include/pupa/fs.h [PUPA_UTIL] (pupa_fat_init): Declared. [PUPA_UTIL] (pupa_fat_fini): Likewise. * fs/fat.c [PUPA_UTIL] (pupa_fat_init): Defined. Maybe a better way should be implemented. [PUPA_UTIL] (pupa_fat_fini): Likewise. * disk/i386/pc/biosdisk.c (pupa_biosdisk_call_hook): Increase the size of NAME for safety. (pupa_biosdisk_iterate): Search hard disks to 0x90 instead of 0x88. * conf/i386-pc.rmk (sbin_UTILITIES): New variable. (pupa_setup_SOURCES): Likewise. * genmk.rb (Utility#rule): Add $(BUILD_CFLAGS) into the rules. 2002-12-28 Yoshinori K. Okuji * kern/i386/pc/startup.S (push_get_mmap_entry): Revert to a bunch of pushl's from pusha, because this destroys the return value. 2002-12-28 Yoshinori K. Okuji Use -mrtd and -mregparm=3 to reduce the generated code sizes. This means that any missing prototypes could be fatal. Also, you must take care when writing assembly code. See the comments at the beginning of startup.S, for more details. * kern/i386/pc/startup.S (pupa_halt): Modified for the new compilation mechanism. (pupa_chainloader_real_boot): Likewise. (pupa_biosdisk_rw_int13_extensions): Likewise. (pupa_biosdisk_rw_standard): Likewise. (pupa_biosdisk_check_int13_extensions): Likewise. (pupa_biosdisk_get_diskinfo_int13_extensions): Likewise. (pupa_biosdisk_get_diskinfo_standard): Likewise. (pupa_get_memsize): Likewise. (pupa_get_mmap_entry): Likewise. (pupa_console_putchar): Likewise. (pupa_console_setcursor): Likewise. (pupa_getrtsecs): Use pushl instead of push. * kern/i386/pc/init.c (pupa_machine_init): Use the scratch memory instead of the stack for a mmap entry, because some BIOSes may ignore the maximum size and overflow. * conf/i386-pc.rmk (COMMON_CFLAGS): Added -mrtd and -mregparm=3. * genmk.rb (PModule#rule): Compile automatically generated sources with module-specific CFLAGS as well as other sources. 2002-12-27 Yoshinori K. Okuji * configure.ac: Check ld. Replace CFLAGS and CPPFLAGS with BUILD_CFLAGS and BUILD_CPPFLAGS respectively, before checking endianness and sizes. * Makefile.in (LD): New variable. 2002-12-27 Yoshinori K. Okuji * Makefile.in (BUILD_CC): CC -> BUILD_CC. 2002-12-27 Yoshinori K. Okuji * Changelog: New file.