diff -burN skyeye-1.0.0/Makefile patched/skyeye-1.0.0/Makefile --- skyeye-1.0.0/Makefile 2005-09-14 17:03:05.000000000 +0200 +++ patched/skyeye-1.0.0/Makefile 2005-09-27 19:43:07.000000000 +0200 @@ -93,7 +93,7 @@ SIM_DEVICE_OBJS = binary/skyeye_device.o $(SIM_NET_OBJS) $(SIM_LCD_OBJS) $(SIM_FLASH_OBJS) -SIM_UTILS_OBJS = binary/skyeye2gdb.o binary/skyeye_config.o binary/skyeye_options.o binary/skyeye_stub_win32.o binary/skyeye.o +SIM_UTILS_OBJS = binary/skyeye2gdb.o binary/skyeye_config.o binary/skyeye_options.o binary/skyeye_stub_win32.o binary/skyeye.o binary/kernel_parameters.o SIM_OBJS = $(SIM_ARM_OBJS) \ $(SIM_MMU_OBJS) \ @@ -202,6 +202,9 @@ binary/skyeye_options.o: $(UTILS_PATH)/config/skyeye_options.c $(UTILS_PATH)/config/skyeye_config.h \ $(ARM_COMMON_PATH)/armdefs.h $(ARM_COMMON_PATH)/armmem.h $(ARM_COMMON_PATH)/armio.h $(CC) -c $< -o $@ $(ALL_CFLAGS) +binary/kernel_parameters.o: $(UTILS_PATH)/config/kernel_parameters.c $(UTILS_PATH)/config/skyeye_config.h \ + $(ARM_COMMON_PATH)/armdefs.h $(ARM_COMMON_PATH)/armmem.h $(ARM_COMMON_PATH)/armio.h + $(CC) -c $< -o $@ $(ALL_CFLAGS) #SIM_MMU_OBJS diff -burN skyeye-1.0.0/utils/config/kernel_parameters.c patched/skyeye-1.0.0/utils/config/kernel_parameters.c --- skyeye-1.0.0/utils/config/kernel_parameters.c 1970-01-01 01:00:00.000000000 +0100 +++ patched/skyeye-1.0.0/utils/config/kernel_parameters.c 2005-09-28 01:16:51.000000000 +0200 @@ -0,0 +1,225 @@ +/* +Based on code from +http://www.simtec.co.uk/products/SWLINUX/files/booting_article.htm +*/ + +#include "skyeye_config.h" + +/* list of possible tags */ +#define ATAG_NONE 0x00000000 +#define ATAG_CORE 0x54410001 +#define ATAG_MEM 0x54410002 +#define ATAG_VIDEOTEXT 0x54410003 +#define ATAG_RAMDISK 0x54410004 +#define ATAG_INITRD2 0x54420005 +#define ATAG_SERIAL 0x54410006 +#define ATAG_REVISION 0x54410007 +#define ATAG_VIDEOLFB 0x54410008 +#define ATAG_CMDLINE 0x54410009 + +/* structures for each atag */ +struct atag_header { + u32 size; /* length of tag in words including this header */ + u32 tag; /* tag type */ +}; + +struct atag_core { + u32 flags; + u32 pagesize; + u32 rootdev; +}; + +struct atag_mem { + u32 size; + u32 start; +}; + +struct atag_videotext { + u8 x; + u8 y; + u16 video_page; + u8 video_mode; + u8 video_cols; + u16 video_ega_bx; + u8 video_lines; + u8 video_isvga; + u16 video_points; +}; + +struct atag_ramdisk { + u32 flags; + u32 size; + u32 start; +}; + +struct atag_initrd2 { + u32 start; + u32 size; +}; + +struct atag_serialnr { + u32 low; + u32 high; +}; + +struct atag_revision { + u32 rev; +}; + +struct atag_videolfb { + u16 lfb_width; + u16 lfb_height; + u16 lfb_depth; + u16 lfb_linelength; + u32 lfb_base; + u32 lfb_size; + u8 red_size; + u8 red_pos; + u8 green_size; + u8 green_pos; + u8 blue_size; + u8 blue_pos; + u8 rsvd_size; + u8 rsvd_pos; +}; + +struct atag_cmdline { + char cmdline[1]; +}; + +struct atag { + struct atag_header hdr; + union { + struct atag_core core; + struct atag_mem mem; + struct atag_videotext videotext; + struct atag_ramdisk ramdisk; + struct atag_initrd2 initrd2; + struct atag_serialnr serialnr; + struct atag_revision revision; + struct atag_videolfb videolfb; + struct atag_cmdline cmdline; + } u; +}; + + +#define tag_next(t) ((struct atag *)((u32 *)(t) + (t)->hdr.size)) +#define tag_size(type) ((sizeof(struct atag_header) + sizeof(struct type)) >> 2) +static struct atag *params; /* used to point at the current tag */ + +static void +setup_core_tag(void * address,long pagesize) +{ + params = (struct atag *)address; /* Initialise parameters to start at given address */ + + params->hdr.tag = ATAG_CORE; /* start with the core tag */ + params->hdr.size = tag_size(atag_core); /* size the tag */ + + params->u.core.flags = 1; /* ensure read-only */ + params->u.core.pagesize = pagesize; /* systems pagesize (4k) */ + params->u.core.rootdev = 0; /* zero root device (typicaly overidden from commandline )*/ + + params = tag_next(params); /* move pointer to next tag */ +} + +static void +setup_ramdisk_tag(u32 size) +{ + params->hdr.tag = ATAG_RAMDISK; /* Ramdisk tag */ + params->hdr.size = tag_size(atag_ramdisk); /* size tag */ + + params->u.ramdisk.flags = 0; /* Load the ramdisk */ + params->u.ramdisk.size = size; /* Decompressed ramdisk size */ + params->u.ramdisk.start = 0; /* Unused */ + + params = tag_next(params); /* move pointer to next tag */ +} + +static void +setup_initrd2_tag(u32 start, u32 size) +{ + params->hdr.tag = ATAG_INITRD2; /* Initrd2 tag */ + params->hdr.size = tag_size(atag_initrd2); /* size tag */ + + params->u.initrd2.start = start; /* physical start */ + params->u.initrd2.size = size; /* compressed ramdisk size */ + + params = tag_next(params); /* move pointer to next tag */ +} + +static void +setup_mem_tag(u32 start, u32 len) +{ + params->hdr.tag = ATAG_MEM; /* Memory tag */ + params->hdr.size = tag_size(atag_mem); /* size tag */ + + params->u.mem.start = start; /* Start of memory area (physical address) */ + params->u.mem.size = len; /* Length of area */ + + params = tag_next(params); /* move pointer to next tag */ +} + +static void +setup_cmdline_tag(const char * line) +{ + int linelen = strlen(line); + + if(!linelen) + return; /* do not insert a tag for an empty commandline */ + + params->hdr.tag = ATAG_CMDLINE; /* Commandline tag */ + params->hdr.size = (sizeof(struct atag_header) + linelen + 1 + 4) >> 2; + + strcpy(params->u.cmdline.cmdline,line); /* place commandline into tag */ + + params = tag_next(params); /* move pointer to next tag */ +} + +static void +setup_end_tag(void) +{ + params->hdr.tag = ATAG_NONE; /* Empty tag ends list */ + params->hdr.size = 0; /* zero length */ +} + + +void +configure_kernel(skyeye_config_t* pConfig, ARMul_State *pState) +{ + char paramBuf[2048]; + mem_bank_t *pBank; + int i; + + printf("configuring kernel\n"); + if (pConfig->kernel_parameters_address == 0) + { + printf("No kernel parameter address\n"); + return; + } + setup_core_tag(paramBuf, 4096); /* standard core tag 4k pagesize */ + for (i=0; imem.mem_banks[i]); + if (pBank->type == MEMTYPE_RAM) { + setup_mem_tag(pBank->addr, pBank->len); + } + + if (pBank->initalRamDisk) { + printf ("ramdisk image found %x, %x\n", pBank->addr, pBank->len); + setup_ramdisk_tag(pConfig->initrd_kb); + setup_initrd2_tag(pBank->addr, pBank->len); + } + + } + + setup_cmdline_tag(pConfig->kernel_ccommand_line); + setup_end_tag(); + + for (i = 0; i < sizeof(paramBuf); i++) + { + ARMul_WriteByte (pState, pConfig->kernel_parameters_address + i, paramBuf[i]); + } + pState->Reg[2] = pConfig->kernel_parameters_address; + +} + + diff -burN skyeye-1.0.0/utils/config/skyeye_config.c patched/skyeye-1.0.0/utils/config/skyeye_config.c --- skyeye-1.0.0/utils/config/skyeye_config.c 2005-09-14 09:32:29.000000000 +0200 +++ patched/skyeye-1.0.0/utils/config/skyeye_config.c 2005-09-27 18:29:31.000000000 +0200 @@ -31,7 +31,7 @@ //int skyeye_instr_debug=0; FILE *skyeye_logfd; - /**/ int +int parse_line_unformatted (char *line) { #define MAX_PARAMS_LEN 40 @@ -61,7 +61,7 @@ ptr = strtok (line, ":"); while ((ptr) && (!comment)) { - string_i = 0; + if (! inquotes) string_i = 0; for (i = 0; i < strlen (ptr); i++) { if (ptr[i] == '"') @@ -77,6 +77,13 @@ string[string_i++] = ptr[i]; } } + + if (inquotes) { + string[string_i++] = ','; + ptr = strtok (NULL, ","); + continue; + } + string[string_i] = '\0'; if (string_i == 0) break; @@ -157,7 +164,6 @@ sop->do_num++; if (sop->do_num > sop->max_do_num) { - /**/ fprintf (stderr, "\"%s\" option has exceeded max number %d!\n", params[0], sop->max_do_num); diff -burN skyeye-1.0.0/utils/config/skyeye_config.h patched/skyeye-1.0.0/utils/config/skyeye_config.h --- skyeye-1.0.0/utils/config/skyeye_config.h 2005-09-14 09:32:29.000000000 +0200 +++ patched/skyeye-1.0.0/utils/config/skyeye_config.h 2005-09-28 01:06:28.000000000 +0200 @@ -163,6 +163,7 @@ unsigned long addr, len; char filename[MAX_STR]; unsigned type; //chy 2003-09-21: maybe io,ram,rom + char initalRamDisk; } mem_bank_t; typedef struct @@ -252,6 +253,7 @@ uart_config_t uart; log_config_t log; ARMword start_address; + ARMword initrd_address; /*ywc 2005-03-31, no_dbct used by Dynamic Binary Code Translation */ ARMword no_dbct; @@ -266,6 +268,11 @@ //teawater add for new tb manage function 2005.07.10---------------------------- uint32_t tb_tbt_size; uint32_t tb_tbp_size; + + ARMword kernel_parameters_address; + char kernel_ccommand_line[256]; + int initrd_kb; + } skyeye_config_t; skyeye_config_t skyeye_config; @@ -285,6 +292,7 @@ int do_log_option (); int do_step_disassemble_option (); +int do_kernel_parameters_option (); #define MAX_OPTION_NAME 32 #define MAX_PARAM_NAME 32 @@ -323,7 +331,9 @@ * with assemble code and may be have some usefull * */ - {"step_disassemble", do_step_disassemble_option, 0, 1} + {"step_disassemble", do_step_disassemble_option, 0, 1}, + + {"kernel_parameters", do_kernel_parameters_option, 0, 1} }; diff -burN skyeye-1.0.0/utils/config/skyeye_options.c patched/skyeye-1.0.0/utils/config/skyeye_options.c --- skyeye-1.0.0/utils/config/skyeye_options.c 2005-09-14 09:32:29.000000000 +0200 +++ patched/skyeye-1.0.0/utils/config/skyeye_options.c 2005-09-28 01:08:36.000000000 +0200 @@ -125,6 +125,14 @@ } +static ARMword parse_address(const char *value) +{ + if (value[0] == '0' && value[1] == 'x') + return strtoul (value, NULL, 16); + else + return strtoul (value, NULL, 10); +} + /* we need init some options before read the option file. * now put them here. * */ @@ -398,26 +406,25 @@ } else if (!strncmp ("addr", name, strlen (name))) { - - if (value[0] == '0' && value[1] == 'x') - mb[num].addr = strtoul (value, NULL, 16); - else - mb[num].addr = strtoul (value, NULL, 10); - + mb[num].addr = parse_address(value); + printf("Bank %d @ %x\n", num, mb[num].addr); } else if (!strncmp ("size", name, strlen (name))) { - if (value[0] == '0' && value[1] == 'x') - mb[num].len = strtoul (value, NULL, 16); - else - mb[num].len = strtoul (value, NULL, 10); + mb[num].len = parse_address(value); + printf("Bank %d len %x\n", num, mb[num].len); } else if (!strncmp ("file", name, strlen (name))) { strncpy (mb[num].filename, value, strlen (value) + 1); } + else if (!strncmp ("initrd", name, strlen (name))) + { + if (!strncmp ("yes", value, strlen (value))) + mb[num].initalRamDisk = 1; + } else if (!strncmp ("boot", name, strlen (name))) { /*this must be the last parameter. */ @@ -764,3 +771,43 @@ SKYEYE_ERR ("Error: Unkonw cpu name \"%s\"\n", params[0]); return -1; } + +int +do_kernel_parameters_option (skyeye_option_t * this_option, int num_params, + const char *params[]) +{ + + int i; + char name[MAX_PARAM_NAME], value[MAX_PARAM_NAME]; + + for (i = 0; i < num_params; i++) { + if (split_param (params[i], name, value) < 0) + { + SKYEYE_ERR + ("kernel_parameters: Error: wrong parameter \"%s\".\n", name); + continue; + } + + if (!strncmp ("addr", name, strlen (name))) + { + skyeye_config.kernel_parameters_address = parse_address(value); + continue; + } + + if (!strncmp ("default_cmdline", name, strlen (name))) + { + if (strlen(skyeye_config.kernel_ccommand_line) == 0) + { + strncpy(skyeye_config.kernel_ccommand_line, value, sizeof(skyeye_config.kernel_ccommand_line-1)); + } else { + printf("ignoring config file kernel command line - using %s\n",skyeye_config.kernel_ccommand_line); + } + } + + if (!strncmp ("initrd_kb", name, strlen (name))) + { + sscanf (value, "%u", &skyeye_config.initrd_kb); + } + + } +} diff -burN skyeye-1.0.0/utils/main/skyeye.c patched/skyeye-1.0.0/utils/main/skyeye.c --- skyeye-1.0.0/utils/main/skyeye.c 2005-09-14 09:46:28.000000000 +0200 +++ patched/skyeye-1.0.0/utils/main/skyeye.c 2005-09-27 19:38:16.000000000 +0200 @@ -321,6 +321,8 @@ //teawater add for load elf 2005.07.31------------------------------------------ char *exec_file = NULL; + memset(&skyeye_config, 0, sizeof(skyeye_config)); + while ((c = getopt (argc, argv, "e:dc:h")) != -1) //AJ2D-------------------------------------------------------------------------- switch (c) @@ -353,7 +355,10 @@ debugmode, skyeye_config_filename); for (index = optind; index < argc; index++) - printf ("Non-option argument %s\n", argv[index]); + { + strcat(skyeye_config.kernel_ccommand_line, argv[index]); + strcat(skyeye_config.kernel_ccommand_line, " "); + } init (); @@ -371,6 +376,8 @@ if (skyeye_config.start_address != 0) ARMul_SetPC (state, skyeye_config.start_address); + configure_kernel(&skyeye_config, state); + if (debugmode == 0) sim_resume (0); else