--- Gnu-Mach/i386/i386at/model_dep.c 2020/09/02 04:46:51 1.1.1.4 +++ Gnu-Mach/i386/i386at/model_dep.c 2020/09/02 04:51:29 1.1.1.6 @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,8 @@ #include #include #include +#include +#include #ifdef MACH_XEN #include #include @@ -74,14 +77,31 @@ #include #endif /* MACH_XEN */ +#if ENABLE_IMMEDIATE_CONSOLE +#include "immc.h" +#endif /* ENABLE_IMMEDIATE_CONSOLE */ + /* Location of the kernel's symbol table. Both of these are 0 if none is available. */ #if MACH_KDB +#include +#include + +/* a.out symbol table */ static vm_offset_t kern_sym_start, kern_sym_end; -#else + +/* ELF section header */ +static unsigned elf_shdr_num; +static vm_size_t elf_shdr_size; +static vm_offset_t elf_shdr_addr; +static unsigned elf_shdr_shndx; + +#else /* MACH_KDB */ #define kern_sym_start 0 #define kern_sym_end 0 -#endif +#endif /* MACH_KDB */ + +#define RESERVED_BIOS 0x10000 /* These indicate the total extent of physical memory addresses we're using. They are page-aligned. */ @@ -113,7 +133,7 @@ char *kernel_cmdline = ""; It is not necessarily page-aligned. */ static vm_offset_t avail_next #ifndef MACH_HYP - = 0x1000 /* XX end of BIOS data area */ + = RESERVED_BIOS /* XX end of BIOS data area */ #endif /* MACH_HYP */ ; @@ -123,14 +143,8 @@ static vm_size_t avail_remaining; extern char version[]; -extern void setup_main(); - -void halt_all_cpus (boolean_t reboot) __attribute__ ((noreturn)); -void halt_cpu (void) __attribute__ ((noreturn)); - -void inittodr(); /* forward */ - -int rebootflag = 0; /* exported to kdintr */ +/* If set, reboot the system on ctrl-alt-delete. */ +boolean_t rebootflag = FALSE; /* exported to kdintr */ /* XX interrupt stack pointer and highwater mark, for locore.S. */ vm_offset_t int_stack_top, int_stack_high; @@ -139,8 +153,6 @@ vm_offset_t int_stack_top, int_stack_hig extern void linux_init(void); #endif -boolean_t init_alloc_aligned(vm_size_t size, vm_offset_t *addrp); - /* * Find devices. The system is alive. */ @@ -184,10 +196,14 @@ void machine_init(void) *(unsigned short *)phystokv(0x472) = 0x1234; #endif /* MACH_HYP */ +#if VM_MIN_KERNEL_ADDRESS == 0 /* * Unmap page 0 to trap NULL references. + * + * Note that this breaks accessing some BIOS areas stored there. */ pmap_unmap_page_zero(); +#endif } /* Conserve power on processor CPU. */ @@ -201,7 +217,7 @@ void machine_idle (int cpu) #endif /* MACH_HYP */ } -void machine_relax () +void machine_relax (void) { asm volatile ("rep; nop" : : : "memory"); } @@ -223,8 +239,7 @@ void halt_cpu(void) /* * Halt the system or reboot. */ -void halt_all_cpus(reboot) - boolean_t reboot; +void halt_all_cpus(boolean_t reboot) { if (reboot) { #ifdef MACH_HYP @@ -233,10 +248,11 @@ void halt_all_cpus(reboot) kdreboot(); } else { - rebootflag = 1; + rebootflag = TRUE; #ifdef MACH_HYP hyp_halt(); #endif /* MACH_HYP */ + grub_acpi_halt(); printf("In tight loop: hit ctl-alt-del to reboot\n"); (void) spl0(); } @@ -249,6 +265,11 @@ void exit(int rc) halt_all_cpus(0); } +void db_halt_cpu(void) +{ + halt_all_cpus(0); +} + void db_reset_cpu(void) { halt_all_cpus(1); @@ -335,7 +356,7 @@ mem_size_init(void) #else /* MACH_HYP */ avail_remaining = phys_last_addr - (0x100000 - (boot_info.mem_lower * 0x400) - - 0x1000); + - RESERVED_BIOS); #endif /* MACH_HYP */ } @@ -374,7 +395,7 @@ i386at_init(void) int len = strlen ((char*)phystokv(boot_info.cmdline)) + 1; assert(init_alloc_aligned(round_page(len), &addr)); kernel_cmdline = (char*) phystokv(addr); - memcpy(kernel_cmdline, (char*)phystokv(boot_info.cmdline), len); + memcpy(kernel_cmdline, (void *)phystokv(boot_info.cmdline), len); boot_info.cmdline = addr; } @@ -526,6 +547,10 @@ i386at_init(void) */ void c_boot_entry(vm_offset_t bi) { +#if ENABLE_IMMEDIATE_CONSOLE + romputc = immc_romputc; +#endif /* ENABLE_IMMEDIATE_CONSOLE */ + /* Stash the boot_image_info pointer. */ boot_info = *(typeof(boot_info)*)phystokv(bi); int cpu_type; @@ -565,6 +590,17 @@ void c_boot_entry(vm_offset_t bi) kern_sym_start, kern_sym_end, symtab_size, strtab_size); } + + if ((boot_info.flags & MULTIBOOT_ELF_SHDR) + && boot_info.syms.e.num) + { + elf_shdr_num = boot_info.syms.e.num; + elf_shdr_size = boot_info.syms.e.size; + elf_shdr_addr = (vm_offset_t)phystokv(boot_info.syms.e.addr); + elf_shdr_shndx = boot_info.syms.e.shndx; + + printf("ELF section header table at %08lx\n", elf_shdr_addr); + } #endif /* MACH_KDB */ #endif /* MACH_XEN */ @@ -581,7 +617,14 @@ void c_boot_entry(vm_offset_t bi) */ if (kern_sym_start) { - aout_db_sym_init(kern_sym_start, kern_sym_end, "mach", 0); + aout_db_sym_init((char *)kern_sym_start, (char *)kern_sym_end, "mach", (char *)0); + } + + if (elf_shdr_num) + { + elf_db_sym_init(elf_shdr_num,elf_shdr_size, + elf_shdr_addr, elf_shdr_shndx, + "mach", NULL); } #endif /* MACH_KDB */ @@ -620,15 +663,13 @@ void c_boot_entry(vm_offset_t bi) #include int -timemmap(dev,off,prot) +timemmap(dev, off, prot) + dev_t dev; + vm_offset_t off; vm_prot_t prot; { extern time_value_t *mtime; -#ifdef lint - dev++; off++; -#endif /* lint */ - if (prot & VM_PROT_WRITE) return (-1); return (i386_btop(pmap_extract(pmap_kernel(), (vm_offset_t) mtime))); @@ -716,7 +757,7 @@ init_alloc_aligned(vm_size_t size, vm_of of free pages, so it should not have been allocated to any other use in early initialization before the Linux driver glue initialization needs to allocate low memory. */ - avail_next = 0x1000; + avail_next = RESERVED_BIOS; wrapped = 1; } } @@ -841,8 +882,7 @@ init_alloc_aligned(vm_size_t size, vm_of return TRUE; } -boolean_t pmap_next_page(addrp) - vm_offset_t *addrp; +boolean_t pmap_next_page(vm_offset_t *addrp) { return init_alloc_aligned(PAGE_SIZE, addrp); } @@ -859,8 +899,7 @@ pmap_grab_page(void) return addr; } -boolean_t pmap_valid_page(x) - vm_offset_t x; +boolean_t pmap_valid_page(vm_offset_t x) { /* XXX is this OK? What does it matter for? */ return (((phys_first_addr <= x) && (x < phys_last_addr))