summaryrefslogtreecommitdiff
path: root/kern/linux
diff options
context:
space:
mode:
authorAli Saidi <saidi@eecs.umich.edu>2004-05-30 17:45:46 -0400
committerAli Saidi <saidi@eecs.umich.edu>2004-05-30 17:45:46 -0400
commit9d0aa1399157bd90436409a7596377b4591a2d4a (patch)
tree1b2fb62a8ce54801572ca863cdf16d566633ef1f /kern/linux
parentac27e69ef9e8d0791bd62f2f912f51f22529a32b (diff)
downloadgem5-9d0aa1399157bd90436409a7596377b4591a2d4a.tar.xz
Cleaned up and commented code. I think we are ready to merge with head.
dev/baddev.hh: dev/pcidev.hh: dev/tsunami.hh: dev/tsunami_cchip.hh: dev/tsunami_io.hh: dev/tsunami_pchip.hh: Added doxygen comments dev/pciconfigall.hh: Added doxygen comments. Made the hlist of devices private and provided members to modify the data. dev/pcidev.cc: updated for change in pciconfigall dev/tsunami_pchip.cc: Deleted commented out code we don't need kern/linux/linux_syscalls.cc: Simplified the number -> name conversion. kern/linux/linux_syscalls.hh: Removed StandardNumber and replaced with Number. kern/linux/linux_system.cc: kern/linux/linux_system.hh: LinuxSkipIdeDelay50msEvent was simply the same as the SkipFunc event, so I removed it. Same with with LinuxSkipFuncEvent. --HG-- extra : convert_revision : 1508c335f87d90373f5772f3a0407ea13e858d7e
Diffstat (limited to 'kern/linux')
-rw-r--r--kern/linux/linux_syscalls.cc6
-rw-r--r--kern/linux/linux_syscalls.hh13
-rw-r--r--kern/linux/linux_system.cc57
-rw-r--r--kern/linux/linux_system.hh22
4 files changed, 65 insertions, 33 deletions
diff --git a/kern/linux/linux_syscalls.cc b/kern/linux/linux_syscalls.cc
index d259499a2..6e8d5d190 100644
--- a/kern/linux/linux_syscalls.cc
+++ b/kern/linux/linux_syscalls.cc
@@ -30,7 +30,7 @@
namespace {
const char *
- standard_strings[SystemCalls<Linux>::StandardNumber] = {
+ standard_strings[SystemCalls<Linux>::Number] = {
"llseek", //0
@@ -367,9 +367,7 @@ namespace {
const char *
SystemCalls<Linux>::name(int num)
{
- if (num >= StandardNumber)
- return 0;
- else if (num >= 0)
+ if ((num >= 0) && (num < Number))
return standard_strings[num];
else
return 0;
diff --git a/kern/linux/linux_syscalls.hh b/kern/linux/linux_syscalls.hh
index d8f2123d7..86ccdd12d 100644
--- a/kern/linux/linux_syscalls.hh
+++ b/kern/linux/linux_syscalls.hh
@@ -308,24 +308,15 @@ struct SystemCalls<Linux>
waitpid = 270,
write = 271,
writev = 272,
- StandardNumber
+ Number
};
- static const int Number = StandardNumber;
-
static const char *name(int num);
static bool validSyscallNumber(int num) {
- return num < StandardNumber;
+ return num < Number;
}
- /* why does this exist, I don't think it is needed for linux */
- static int convert(int syscall_num) {
- if (!validSyscallNumber(syscall_num))
- return -1;
-
- return syscall_num ;
- }
};
#endif // __LINUX_SYSCALLS_HH__
diff --git a/kern/linux/linux_system.cc b/kern/linux/linux_system.cc
index 06d30bfab..89688772c 100644
--- a/kern/linux/linux_system.cc
+++ b/kern/linux/linux_system.cc
@@ -26,6 +26,14 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * @file
+ * linux_system.cc loads the linux kernel, console, pal and patches certain functions.
+ * The symbol tables are loaded so that traces can show the executing function and we can
+ * skip functions. Various delay loops are skipped and their final values manually computed to
+ * speed up boot time.
+ */
+
#include "base/loader/aout_object.hh"
#include "base/loader/elf_object.hh"
#include "base/loader/object_file.hh"
@@ -36,6 +44,7 @@
#include "cpu/base_cpu.hh"
#include "kern/linux/linux_events.hh"
#include "kern/linux/linux_system.hh"
+#include "kern/system_events.hh"
#include "mem/functional_mem/memory_control.hh"
#include "mem/functional_mem/physical_memory.hh"
#include "sim/builder.hh"
@@ -58,6 +67,9 @@ LinuxSystem::LinuxSystem(const string _name, const uint64_t _init_param,
kernelSymtab = new SymbolTable;
consoleSymtab = new SymbolTable;
+ /**
+ * Load the kernel, pal, and console code into memory
+ */
// Load kernel code
ObjectFile *kernel = createObjectFile(kernel_path);
if (kernel == NULL)
@@ -107,16 +119,22 @@ LinuxSystem::LinuxSystem(const string _name, const uint64_t _init_param,
consolePanicEvent = new BreakPCEvent(&pcEventQueue, "console panic");
#endif
- skipIdeDelay50msEvent = new LinuxSkipIdeDelay50msEvent(&pcEventQueue,
- "ide_delay_50ms");
+ skipIdeDelay50msEvent = new SkipFuncEvent(&pcEventQueue,
+ "ide_delay_50ms");
skipDelayLoopEvent = new LinuxSkipDelayLoopEvent(&pcEventQueue,
"calibrate_delay");
- skipCacheProbeEvent = new LinuxSkipFuncEvent(&pcEventQueue, "determine_cpu_caches");
+ skipCacheProbeEvent = new SkipFuncEvent(&pcEventQueue,
+ "determine_cpu_caches");
Addr addr = 0;
+ /**
+ * find the address of the est_cycle_freq variable and insert it so we don't
+ * through the lengthly process of trying to calculated it by using the PIT,
+ * RTC, etc.
+ */
if (kernelSymtab->findAddress("est_cycle_freq", addr)) {
Addr paddr = vtophys(physmem, addr);
uint8_t *est_cycle_frequency =
@@ -127,6 +145,11 @@ LinuxSystem::LinuxSystem(const string _name, const uint64_t _init_param,
}
+ /**
+ * Copy the osflags (kernel arguments) into the consoles memory. Presently
+ * Linux does use the console service routine to get these command line
+ * arguments, but we might as well make them available just in case.
+ */
if (consoleSymtab->findAddress("env_booted_osflags", addr)) {
Addr paddr = vtophys(physmem, addr);
char *osflags = (char *)physmem->dma_addr(paddr, sizeof(uint32_t));
@@ -135,6 +158,10 @@ LinuxSystem::LinuxSystem(const string _name, const uint64_t _init_param,
strcpy(osflags, boot_osflags.c_str());
}
+ /**
+ * 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));
@@ -143,13 +170,17 @@ LinuxSystem::LinuxSystem(const string _name, const uint64_t _init_param,
}
+ /**
+ * Set the hardware reset parameter block system type and revision information
+ * to Tsunami.
+ */
if (consoleSymtab->findAddress("xxm_rpb", addr)) {
Addr paddr = vtophys(physmem, addr);
char *hwprb = (char *)physmem->dma_addr(paddr, sizeof(uint64_t));
if (hwprb) {
*(uint64_t*)(hwprb+0x50) = 34; // Tsunami
- *(uint64_t*)(hwprb+0x58) = (1<<10);
+ *(uint64_t*)(hwprb+0x58) = (1<<10); // Plain DP264
}
else
panic("could not translate hwprb addr to set system type/variation\n");
@@ -167,14 +198,20 @@ LinuxSystem::LinuxSystem(const string _name, const uint64_t _init_param,
consolePanicEvent->schedule(addr);
#endif
+ /**
+ * Any time ide_delay_50ms, calibarte_delay or determine_cpu_caches is called
+ * just skip the function. Currently determine_cpu_caches only is used put
+ * information in proc, however if that changes in the future we will have to
+ * fill in the cache size variables appropriately.
+ */
if (kernelSymtab->findAddress("ide_delay_50ms", addr))
- skipIdeDelay50msEvent->schedule(addr+8);
+ skipIdeDelay50msEvent->schedule(addr+sizeof(MachInst));
if (kernelSymtab->findAddress("calibrate_delay", addr))
- skipDelayLoopEvent->schedule(addr+8);
+ skipDelayLoopEvent->schedule(addr+sizeof(MachInst));
if (kernelSymtab->findAddress("determine_cpu_caches", addr))
- skipCacheProbeEvent->schedule(addr+8);
+ skipCacheProbeEvent->schedule(addr+sizeof(MachInst));
}
LinuxSystem::~LinuxSystem()
@@ -224,7 +261,11 @@ LinuxSystem::registerExecContext(ExecContext *xc)
RemoteGDB *rgdb = new RemoteGDB(this, xc);
GDBListener *gdbl = new GDBListener(rgdb, 7000 + xcIndex);
gdbl->listen();
-// gdbl->accept();
+ /**
+ * Uncommenting this line waits for a remote debugger to connect
+ * to the simulator before continuing.
+ */
+ //gdbl->accept();
if (remoteGDB.size() <= xcIndex) {
remoteGDB.resize(xcIndex+1);
diff --git a/kern/linux/linux_system.hh b/kern/linux/linux_system.hh
index 3f743306a..b9f301c60 100644
--- a/kern/linux/linux_system.hh
+++ b/kern/linux/linux_system.hh
@@ -37,6 +37,10 @@
#include <map>
+/**
+ * MAGIC address where the kernel arguments should go. Defined as
+ * PARAM in linux kernel alpha-asm.
+ */
const Addr PARAM_ADDR = ULL(0xfffffc000030a000);
class ExecContext;
@@ -44,15 +48,16 @@ class ElfObject;
class SymbolTable;
class BreakPCEvent;
-class LinuxBadAddrEvent;
-class LinuxSkipFuncEvent;
class LinuxSkipDelayLoopEvent;
-class LinuxSkipIdeDelay50msEvent;
-class LinuxPrintfEvent;
-class LinuxDebugPrintfEvent;
+class SkipFuncEvent;
class FnEvent;
class AlphaArguments;
+/**
+ * This class contains linux specific system code (Loading, Events, Binning).
+ * It points to objects that are the system binaries to load and patches them
+ * appropriately to work in simulator.
+ */
class LinuxSystem : public System
{
private:
@@ -64,12 +69,10 @@ class LinuxSystem : public System
BreakPCEvent *kernelPanicEvent;
BreakPCEvent *consolePanicEvent;
- LinuxSkipFuncEvent *skipCacheProbeEvent;
- LinuxSkipIdeDelay50msEvent *skipIdeDelay50msEvent;
+ SkipFuncEvent *skipCacheProbeEvent;
+ SkipFuncEvent *skipIdeDelay50msEvent;
LinuxSkipDelayLoopEvent *skipDelayLoopEvent;
- private:
-
Addr kernelStart;
Addr kernelEnd;
Addr kernelEntry;
@@ -80,7 +83,6 @@ class LinuxSystem : public System
std::vector<RemoteGDB *> remoteGDB;
std::vector<GDBListener *> gdbListen;
- public:
LinuxSystem(const std::string _name,
const uint64_t _init_param,
MemoryController *_memCtrl,