Commit Graph

8814 Commits

Author SHA1 Message Date
gniibe 977329f5fa hello module and bug fix of util/resolve.c 2003-02-08 08:15:43 +00:00
okuji 1f5ab4280a 2003-01-31 Yoshinori K. Okuji <okuji@enbug.org>
* 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-31 03:26:56 +00:00
okuji ce5bf700ca 2003-01-20 Yoshinori K. Okuji <okuji@enbug.org>
* 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  <okuji@enbug.org>

	* 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-20 04:13:46 +00:00
okuji 82cefbd307 Update TODO. 2003-01-17 05:04:20 +00:00
okuji c04da07444 2003-01-17 Yoshinori K. Okuji <okuji@enbug.org>
* 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-17 02:52:05 +00:00
okuji a13f92373c 2003-01-07 Yoshinori K. Okuji <okuji@enbug.org>
* 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-07 07:54:07 +00:00
okuji a5ffe96617 2003-01-06 Yoshinori K. Okuji <okuji@enbug.org>
* 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-06 00:01:35 +00:00
okuji 012d7999fe 2003-01-03 Yoshinori K. Okuji <okuji@enbug.org>
* 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-02 23:46:21 +00:00
okuji 1cc73a62da 2003-01-03 Yoshinori K. Okuji <okuji@enbug.org>
* 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.
2003-01-02 20:12:33 +00:00
okuji 08b70fe8eb 2002-12-28 Yoshinori K. Okuji <okuji@enbug.org>
* 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 07:42:12 +00:00
okuji 62ddcc8f79 2002-12-28 Yoshinori K. Okuji <okuji@enbug.org>
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-28 07:16:30 +00:00
okuji 9962ed9907 2002-12-27 Yoshinori K. Okuji <okuji@enbug.org>
* 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 14:14:06 +00:00
okuji abdfc3c54e 2002-12-27 Yoshinori K. Okuji <okuji@enbug.org>
* Makefile.in (BUILD_CC): CC -> BUILD_CC.
2002-12-27 08:57:45 +00:00
okuji 6a161fa938 Initial revision 2002-12-27 08:53:07 +00:00