#ifndef ARM_LINUX_LOADER_H #define ARM_LINUX_LOADER_H #include #include #include //#include #include #include #include #include #include "systemc.h" #include "tlm.h" #include "tlm_utils/simple_initiator_socket.h" // Memory based at 0 #define DEFAULT_PHYSICAL_BASE 0 // 128MBytes Memory #define DEFAULT_MEMSIZE (128*1024*1024) // command line sits within the boot memory! #define MAX_COMMAND_LINE 256 #define BOOT_MAX_SIZE (MAX_COMMAND_LINE + 512) // Need to define the TLB page size used in the target processor // this is used to align the loaded initrd onto the next page boundary #define TARGET_PAGE_BITS 12 #define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) #define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1) #define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) #define KERNEL_ARGS_ADDR 0x100 #define KERNEL_LOAD_ADDR 0x00010000 #define INITRD_LOAD_ADDR 0x00800000 #define BYTES_PER_ACCESS 128 #ifndef O_BINARY #define O_BINARY 0 #endif struct arm_boot_info { uint32_t ram_size; const char *kernel_filename; const char *kernel_cmdline; const char *initrd_filename; uint32_t loader_start; uint32_t nb_cpus; uint32_t board_id; }; class ARMLinuxLoader : public sc_core::sc_module { public: ARMLinuxLoader(sc_core::sc_module_name name, bool enable); ARMLinuxLoader(sc_core::sc_module_name name, bool enable, const char * kernelfile, const char * initrdfile ); ARMLinuxLoader(sc_core::sc_module_name name, bool enable, const char * kernelfile, const char * initrdfile, const char * commandString ); void arm_load_kernel(); tlm_utils::simple_initiator_socket isocket; private: bool enable; std::string kernelfile; std::string initrdfile; std::string commandString; std::string endianString; uint32_t memsize; uint32_t physicalbase; char window_bootrom[BOOT_MAX_SIZE]; uint32_t window_bootrom_used; arm_boot_info integrator_binfo; const char * kernelfileP; const char * initrdfileP; const char * commandStringP; void fixed_configuration(); int load_image(const char *filename, uint32_t addr); void set_kernel_args(struct arm_boot_info *info,int initrd_size); void write_memory(uint32_t address, int length, unsigned char *data); }; #endif