summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2005-08-23 11:47:12 -0400
committerNathan Binkert <binkertn@umich.edu>2005-08-23 11:47:12 -0400
commitc0de2e7f122924683b5ae2a3a7ce50ce90cf9d73 (patch)
tree0b63b65955fa4f23d79153f874b626ad0a8101d7
parentc761aaae652b101959a6f5e182b67f841727de85 (diff)
downloadgem5-c0de2e7f122924683b5ae2a3a7ce50ce90cf9d73.tar.xz
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
-rw-r--r--kern/linux/linux_system.cc34
-rw-r--r--kern/linux/linux_system.hh26
2 files changed, 40 insertions, 20 deletions
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));
@@ -70,25 +88,13 @@ 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.
* @todo At some point we should change ev5.hh and the palcode to support
* 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) {
diff --git a/kern/linux/linux_system.hh b/kern/linux/linux_system.hh
index 32b92f310..2ddddbc1a 100644
--- a/kern/linux/linux_system.hh
+++ b/kern/linux/linux_system.hh
@@ -29,12 +29,6 @@
#ifndef __KERN_LINUX_LINUX_SYSTEM_HH__
#define __KERN_LINUX_LINUX_SYSTEM_HH__
-/**
- * MAGIC address where the kernel arguments should go. Defined as
- * PARAM in linux kernel alpha-asm.
- */
-const Addr PARAM_ADDR = ULL(0xfffffc000030a000);
-
class ExecContext;
class BreakPCEvent;
@@ -53,6 +47,26 @@ class PrintThreadInfo;
class LinuxSystem : public System
{
private:
+ /**
+ * Addresses defining where the kernel bootloader places various
+ * elements. Details found in include/asm-alpha/system.h
+ */
+ Addr KernelStart; // Lookup the symbol swapper_pg_dir
+
+ public:
+ Addr InitStack() const { return KernelStart + 0x02000; }
+ Addr EmptyPGT() const { return KernelStart + 0x04000; }
+ Addr EmptyPGE() const { return KernelStart + 0x08000; }
+ Addr ZeroPGE() const { return KernelStart + 0x0A000; }
+ Addr StartAddr() const { return KernelStart + 0x10000; }
+
+ Addr Param() const { return ZeroPGE() + 0x0; }
+ Addr CommandLine() const { return Param() + 0x0; }
+ Addr InitrdStart() const { return Param() + 0x100; }
+ Addr InitrdSize() const { return Param() + 0x108; }
+ static const int CommandLineSize = 256;
+
+ private:
#ifndef NDEBUG
/** Event to halt the simulator if the kernel calls panic() */
BreakPCEvent *kernelPanicEvent;