From e253ede76350c4b63552fb9fa2ab251200bba4d6 Mon Sep 17 00:00:00 2001 From: marcel Date: Sun, 3 Apr 2011 22:31:51 +0000 Subject: Add 2 new archsw interfaces: 1. arch_loadaddr - used by platform code to adjust the address at which the object gets loaded. Implement PC98 using this new interface instead of using conditional compilation. For ELF objects the ELF header is passed as the data pointer. For raw files it's the filename. Note that ELF objects are first considered as raw files. 2. arch_loadseg - used by platform code to keep track of actual segments, so that (instruction) caches can be flushed or translations can be created. Both the ELF header as well as the program header are passed to allow platform code to treat the kernel proper differently from any additional modules and to have all the relevant details of the loaded segment (e.g. protection). --- sys/boot/common/module.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'sys/boot/common/module.c') diff --git a/sys/boot/common/module.c b/sys/boot/common/module.c index 063fcdf..728992d 100644 --- a/sys/boot/common/module.c +++ b/sys/boot/common/module.c @@ -275,6 +275,9 @@ file_load(char *filename, vm_offset_t dest, struct preloaded_file **result) int error; int i; + if (archsw.arch_loadaddr != NULL) + dest = archsw.arch_loadaddr(LOAD_RAW, filename, dest); + error = EFTYPE; for (i = 0, fp = NULL; file_formats[i] && fp == NULL; i++) { error = (file_formats[i]->l_load)(filename, loadaddr, &fp); @@ -352,9 +355,6 @@ file_loadraw(char *type, char *name) char *cp; int fd, got; vm_offset_t laddr; -#ifdef PC98 - struct stat st; -#endif /* We can't load first */ if ((file_findfile(NULL, NULL)) == NULL) { @@ -369,20 +369,15 @@ file_loadraw(char *type, char *name) return(CMD_ERROR); } name = cp; - + if ((fd = open(name, O_RDONLY)) < 0) { sprintf(command_errbuf, "can't open '%s': %s", name, strerror(errno)); free(name); return(CMD_ERROR); } -#ifdef PC98 - /* We cannot use 15M-16M area on pc98. */ - if (loadaddr < 0x1000000 && - fstat(fd, &st) == 0 && - (st.st_size == -1 || loadaddr + st.st_size > 0xf00000)) - loadaddr = 0x1000000; -#endif + if (archsw.arch_loadaddr != NULL) + loadaddr = archsw.arch_loadaddr(LOAD_RAW, name, loadaddr); laddr = loadaddr; for (;;) { @@ -489,14 +484,6 @@ mod_loadkld(const char *kldname, int argc, char *argv[]) ; do { -#ifdef PC98 - /* We cannot use 15M-16M area on pc98. */ - struct stat st; - if (loadaddr < 0x1000000 && - stat(filename, &st) == 0 && - (st.st_size == -1 || loadaddr + st.st_size > 0xf00000)) - loadaddr = 0x1000000; -#endif err = file_load(filename, loadaddr, &fp); if (err) break; -- cgit v1.1