From 9d0aa1399157bd90436409a7596377b4591a2d4a Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Sun, 30 May 2004 17:45:46 -0400 Subject: 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 --- kern/linux/linux_syscalls.cc | 6 ++--- kern/linux/linux_syscalls.hh | 13 ++-------- kern/linux/linux_system.cc | 57 +++++++++++++++++++++++++++++++++++++------- kern/linux/linux_system.hh | 22 +++++++++-------- 4 files changed, 65 insertions(+), 33 deletions(-) (limited to 'kern') 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::StandardNumber] = { + standard_strings[SystemCalls::Number] = { "llseek", //0 @@ -367,9 +367,7 @@ namespace { const char * SystemCalls::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 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 +/** + * 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; std::vector gdbListen; - public: LinuxSystem(const std::string _name, const uint64_t _init_param, MemoryController *_memCtrl, -- cgit v1.2.3