From c0de2e7f122924683b5ae2a3a7ce50ce90cf9d73 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Tue, 23 Aug 2005 11:47:12 -0400 Subject: Clean up the passing of the boot command line to the kernel. kern/linux/linux_system.cc: Don't hard code the address of the command line in the kernel, instead, deduce it from the location of known symbols. don't use strcpy, it's dangerous. kern/linux/linux_system.hh: Don't hard code the address of the command line in the kernel, instead, deduce it from the location of known symbols. --HG-- extra : convert_revision : 128b1d5dbd00b0b8571707da99f86f76e29abfd1 --- kern/linux/linux_system.cc | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'kern/linux/linux_system.cc') diff --git a/kern/linux/linux_system.cc b/kern/linux/linux_system.cc index 3f360efdd..e3b9990c5 100644 --- a/kern/linux/linux_system.cc +++ b/kern/linux/linux_system.cc @@ -52,6 +52,24 @@ LinuxSystem::LinuxSystem(Params *p) : System(p) { Addr addr = 0; + Addr paddr = 0; + + /** + * The symbol swapper_pg_dir marks the beginning of the kernel and + * the location of bootloader passed arguments + */ + if (!kernelSymtab->findAddress("swapper_pg_dir", KernelStart)) { + panic("Could not determine start location of kernel"); + } + + /** + * Since we aren't using a bootloader, we have to copy the + * kernel arguments directly into the kernel's memory. + */ + paddr = vtophys(physmem, CommandLine()); + char *commandline = (char *)physmem->dma_addr(paddr, sizeof(uint64_t)); + if (commandline) + strncpy(commandline, params->boot_osflags.c_str(), CommandLineSize); /** * find the address of the est_cycle_freq variable and insert it @@ -59,7 +77,7 @@ LinuxSystem::LinuxSystem(Params *p) * calculated it by using the PIT, RTC, etc. */ if (kernelSymtab->findAddress("est_cycle_freq", addr)) { - Addr paddr = vtophys(physmem, addr); + paddr = vtophys(physmem, addr); uint8_t *est_cycle_frequency = physmem->dma_addr(paddr, sizeof(uint64_t)); @@ -69,18 +87,6 @@ LinuxSystem::LinuxSystem(Params *p) } - /** - * Since we aren't using a bootloader, we have to copy the kernel arguments - * directly into the kernels memory. - */ - { - Addr paddr = vtophys(physmem, PARAM_ADDR); - char *commandline = (char*)physmem->dma_addr(paddr, sizeof(uint64_t)); - if (commandline) - strcpy(commandline, params->boot_osflags.c_str()); - } - - /** * EV5 only supports 127 ASNs so we are going to tell the kernel that the * paritiuclar EV6 we have only supports 127 asns. @@ -88,7 +94,7 @@ LinuxSystem::LinuxSystem(Params *p) * 255 ASNs. */ if (kernelSymtab->findAddress("dp264_mv", addr)) { - Addr paddr = vtophys(physmem, addr); + paddr = vtophys(physmem, addr); char *dp264_mv = (char *)physmem->dma_addr(paddr, sizeof(uint64_t)); if (dp264_mv) { -- cgit v1.2.3