static uint32_t mem_read_byte (uint32_t addr) { uint32_t data, offset; mem_bank_t * global_mbp = bank_ptr(addr); if(global_mbp == NULL){ printf("Can not find the suitable bank for the address 0x%x\n", addr); return 0; } mem_config_t * memmap = get_global_memmap(); mem_state_t * memory = get_global_memory(); generic_arch_t* arch_instance = get_arch_instance(NULL); /* judge the alignment */ if(arch_instance->alignment == Align) { data = memory->rom[global_mbp - memmap->mem_banks][(addr - global_mbp-> addr) >> 2]; }
/** * parse_mem - parse the option from skyeye.conf to get mem info * @num_params: number of parameters * @params: parameter array */ static int parse_mem(int num_params, const char* params[]) { char name[MAX_PARAM_NAME], value[MAX_PARAM_NAME]; int i, num; mem_config_t *mc = get_global_memmap(); mem_bank_t *mb = mc->mem_banks; skyeye_config_t* config = get_current_config(); mc->bank_num = mc->current_num++; num = mc->current_num - 1; /*mem_banks should begin from 0. */ mb[num].filename[0] = '\0'; for (i = 0; i < num_params; i++) { if (split_param (params[i], name, value) < 0) SKYEYE_ERR ("Error: mem_bank %d has wrong parameter \"%s\".\n", num, name); if (!strncmp ("map", name, strlen (name))) { if (!strncmp ("M", value, strlen (value))) { mb[num].bank_read = mem_read; mb[num].bank_write = mem_write; mb[num].type = MEMTYPE_RAM; } else if (!strncmp ("I", value, strlen (value))) { mb[num].bank_read = io_read; mb[num].bank_write = io_write; mb[num].type = MEMTYPE_IO; } else if (!strncmp ("F", value, strlen (value))) { mb[num].bank_read = flash_read; mb[num].bank_write = flash_write; mb[num].type = MEMTYPE_FLASH; } else { SKYEYE_ERR ("Error: mem_bank %d \"%s\" parameter has wrong value \"%s\"\n", num, name, value); } } else if (!strncmp ("type", name, strlen (name))) { //chy 2003-09-21: process type if (!strncmp ("R", value, strlen (value))) { if (mb[num].type == MEMTYPE_RAM) mb[num].type = MEMTYPE_ROM; mb[num].bank_write = warn_write; } } 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); } 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); } else if (!strncmp ("file", name, strlen (name))) { strncpy (mb[num].filename, value, strlen (value) + 1); } else if (!strncmp ("boot", name, strlen (name))) { /*this must be the last parameter. */ if (!strncmp ("yes", value, strlen (value))) config->start_address = mb[num].addr; } else { SKYEYE_ERR ("Error: mem_bank %d has unknow parameter \"%s\".\n", num, name); } } return 0; }