📄 skyeye_options.c
字号:
/*
skyeye_options.c - skyeye config file options' functions
Copyright (C) 2003 Skyeye Develop Group
for help please send mail to <skyeye-developer@lists.sf.linuxforum.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* 08/20/2003 add log option function
chenyu
4/02/2003 add net option function
* walimis <walimi@peoplemail.com.cn>
* 3/22/2003 add cpu, mem_num, mem_bank, arch, dummy option function
* walimis <walimi@peoplemail.com.cn>
* */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "armdefs.h"
#include "skyeye_options.h"
extern FILE *skyeye_logfd;
extern void at91_mach_init ();
extern void ep7312_mach_init ();
extern void lh79520_mach_init ();
extern void ep9312_mach_init ();
extern void s3c4510b_mach_init ();
extern void s3c44b0_mach_init ();
extern void sa1100_mach_init ();
extern void pxa250_mach_init ();
extern void pxa270_mach_init ();
extern void cs89712_mach_init ();
extern void at91rm92_mach_init ();
extern void s3c2410x_mach_init ();
extern void s3c2440_mach_init ();
extern void shp_mach_init ();
extern void lpc_mach_init ();
extern void ns9750_mach_init ();
//chy 2003-08-11: the cpu_id can be found in linux/arch/arm/boot/compressed/head.S
cpu_config_t arm_cpu[] = {
{"armv3", "arm710", 0x41007100, 0xfff8ff00, DATACACHE},
{"armv3", "arm7tdmi", 0x41007700, 0xfff8ff00, NONCACHE},
{"armv4", "arm720t", 0x41807200, 0xffffff00, DATACACHE},
{"armv4", "sa1110", SA1110, 0xfffffff0, INSTCACHE},
{"armv4", "sa1100", SA1100, 0xffffffe0, INSTCACHE},
{"armv4", "arm920t", 0x41009200, 0xff00fff0, INSTCACHE},
{"armv5", "arm926ejs", 0x41069260, 0xff0ffff0, INSTCACHE},
{"xscale", "pxa25x", PXA250, 0xfffffff0, INSTCACHE},
{"xscale", "pxa27x", PXA270, 0xfffffff0, INSTCACHE}
};
machine_config_t arm_machines[] = {
/*machine define for cpu without mmu */
/* ATMEL AT91X40 */
{"at91", at91_mach_init, NULL, NULL, NULL},
/* PHILIPS LPC2xxxx */
{"lpc", lpc_mach_init, NULL, NULL, NULL},
/*Samsung s3c4510b */
{"s3c4510b", s3c4510b_mach_init, NULL, NULL, NULL},
/*Samsung s3c44b0 */
{"s3c44b0", s3c44b0_mach_init, NULL, NULL, NULL},
/*machine define for cpu with mmu */
/* Cirrus Logic EP7312 */
{"ep7312", ep7312_mach_init, NULL, NULL, NULL},
/* sharp LH79520 */
{"lh79520", lh79520_mach_init, NULL, NULL, NULL},
/* Cirrus Logic EP9312 */
{"ep9312", ep9312_mach_init, NULL, NULL, NULL},
/*machine define for cs89712 */
{"cs89712", cs89712_mach_init, NULL, NULL, NULL},
/*machine define for sa1100 */
{"sa1100", sa1100_mach_init, NULL, NULL, NULL},
/*machine define for xscale pxa250 lubbock developboard */
{"pxa_lubbock", pxa250_mach_init, NULL, NULL, NULL},
/*machine define for xscale pxa270 mainstone developboard */
{"pxa_mainstone", pxa270_mach_init, NULL, NULL, NULL},
/*machine define for at91RM9200 */
{"at91rm92", at91rm92_mach_init, NULL, NULL, NULL},
/*machine define for s3c2410x */
{"s3c2410x", s3c2410x_mach_init, NULL, NULL, NULL},
/*machine define for s3c2440 */
{"s3c2440", s3c2410x_mach_init, NULL, NULL, NULL},
/*machine define for sharp lh7a400 developboard */
{"sharp_lh7a400", shp_mach_init, NULL, NULL, NULL},
/*machine define for NetSilicon ns9750 */
{"ns9750", ns9750_mach_init, NULL, NULL, NULL}
};
extern ARMword skyeye_cachetype;
int
split_param (const char *param, char *name, char *value)
{
const char *src = param;
char *dst = name;
while (*src && (*src != '='))
*dst++ = *src++;
*dst = '\0';
if (*src == '\0')
{
value = '\0';
return -1;
}
strcpy (value, src + 1);
return 0;
}
/* we need init some options before read the option file.
* now put them here.
* */
//chy 2004-12-05 for eclipse
//#define SKYEYE4ECLIPSE
#ifdef SKYEYE4ECLIPSE
extern char *inferior_io_terminal;
int nouart;
#endif
//------------------------------
int
skyeye_option_init (skyeye_config_t * config)
{
//chy 2004-12-05 for eclipse
#ifdef SKYEYE4ECLIPSE
int fd;
#endif
//------------------------------
config->uart.fd_in = 0; /*stdin */
config->uart.fd_out = 1; /*stdout */
/*ywc 2005-04-01 */
config->no_dbct = 1; /*default, dbct is off */
//teawater add for new tb manage function 2005.07.10----------------------------
config->tb_tbt_size = 0;
config->tb_tbp_size = TB_TBP_DEFAULT;
//chy 2004-12-05 for eclipse
#ifdef SKYEYE4ECLIPSE
nouart = 0;
if (inferior_io_terminal != NULL)
{
nouart = 1;
printf ("SKYEYE: inferior_io_terminal is %s \n", inferior_io_terminal);
if ((fd = open (inferior_io_terminal, O_RDWR)) == -1)
SKYEYE_DBG ("Error when open device %s", inferior_io_terminal);
skyeye_config.uart.fd_in = fd;
skyeye_config.uart.fd_out = fd;
}
#endif
//------------------------------
}
int
do_dummy_option (skyeye_option_t * this_option, int num_params,
const char *params[])
{
return 0;
};
/* parse "int" parameters. e.g. int=16:17*/
int
get_interrupts (char value[], u32 * interrupts)
{
char *cur = value;
char *next = value;
int i = 0, end = 0;
while ((*next != ':') && (*next != 0))
next++;
while (*cur != 0)
{
if (*next != 0)
{
*next = '\0';
}
else
end = 1;
interrupts[i] = strtoul (cur, NULL, 0);
//printf("%s:%s\n", __FUNCTION__, cur);
i++;
if ((i > 4) || end == 1)
return 0;
cur = ++next;
while ((*next != ':') && (*next != 0))
next++;
}
return 0;
}
/* setup device option.
* all device options may have common parameters. Here we handle these common parameters.
* */
int
setup_device_option (char *option_name, void *dev_option,
int num_params, const char *params[])
{
char name[MAX_PARAM_NAME], value[MAX_PARAM_NAME];
struct common_config conf;
int i;
memset (&conf, 0, sizeof (conf));
conf.type = NULL;
conf.name = NULL;
for (i = 0; i < num_params; i++)
{
if (split_param (params[i], name, value) < 0)
SKYEYE_ERR
("Error: \"%s\" has wrong parameter \"%s\".\n", option_name, name);
if (!strncmp ("type", name, strlen (name)))
{
conf.type = strdup (value);
}
else if (!strncmp ("name", name, strlen (name)))
{
conf.name = strdup (value);
}
else if (!strncmp ("base", name, strlen (name)))
{
conf.base = strtoul (value, NULL, 0);
}
else if (!strncmp ("size", name, strlen (name)))
{
conf.size = strtoul (value, NULL, 0);
}
else if (!strncmp ("int", name, strlen (name)))
{
get_interrupts (value, conf.interrupts);
}
}
setup_device (option_name, &conf, dev_option, skyeye_config.mach);
if (conf.type)
free (conf.type);
if (conf.name)
free (conf.name);
return 0;
}
int
do_cpu_option (skyeye_option_t * this_option, int num_params,
const char *params[])
{
int i;
cpu_config_t *cpu = skyeye_config.cpu;
for (i = 0; i < (sizeof (arm_cpu) / sizeof (cpu_config_t)); i++)
{
if (!strncmp (params[0], arm_cpu[i].cpu_name, MAX_PARAM_NAME))
{
skyeye_config.cpu = &arm_cpu[i];
SKYEYE_INFO ("cpu info: %s, %s, %x, %x, %x \n",
skyeye_config.cpu->cpu_arch_name,
skyeye_config.cpu->cpu_name,
skyeye_config.cpu->cpu_val,
skyeye_config.cpu->cpu_mask,
skyeye_config.cpu->cachetype);
skyeye_cachetype = skyeye_config.cpu->cachetype;
return 0;
}
}
SKYEYE_ERR ("Error: Unkonw cpu name \"%s\"\n", params[0]);
return -1;
}
int
do_mach_option (skyeye_option_t * this_option, int num_params,
const char *params[])
{
int i;
for (i = 0; i < (sizeof (arm_machines) / sizeof (machine_config_t)); i++)
{
if (!strncmp (params[0], arm_machines[i].machine_name, MAX_PARAM_NAME))
{
skyeye_config.mach = &arm_machines[i];
SKYEYE_INFO
("mach info: name %s, mach_init addr %p\n",
skyeye_config.mach->machine_name, skyeye_config.mach->mach_init);
return 0;
}
}
SKYEYE_ERR ("Error: Unkonw mach name \"%s\"\n", params[0]);
return -1;
}
/*mem bank*/
extern ARMword real_read_word (ARMul_State * state, ARMword addr);
extern void real_write_word (ARMul_State * state, ARMword addr, ARMword data);
extern ARMword io_read_word (ARMul_State * state, ARMword addr);
extern void io_write_word (ARMul_State * state, ARMword addr, ARMword data);
/*ywc 2005-03-30*/
extern ARMword flash_read_byte (ARMul_State * state, ARMword addr);
extern void flash_write_byte (ARMul_State * state, ARMword addr,
ARMword data);
extern ARMword flash_read_halfword (ARMul_State * state, ARMword addr);
extern void flash_write_halfword (ARMul_State * state, ARMword addr,
ARMword data);
extern ARMword flash_read_word (ARMul_State * state, ARMword addr);
extern void flash_write_word (ARMul_State * state, ARMword addr,
ARMword data);
int
do_mem_bank_option (skyeye_option_t * this_option, int num_params,
const char *params[])
{
char name[MAX_PARAM_NAME], value[MAX_PARAM_NAME];
int i, num;
//chy 2003-09-12, now support more io bank
// static int io_bank_num=0;
mem_config_t *mc = &skyeye_config.mem;
mem_bank_t *mb = mc->mem_banks;
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].read_byte = real_read_byte;
mb[num].write_byte = real_write_byte;
mb[num].read_halfword = real_read_halfword;
mb[num].write_halfword = real_write_halfword;
mb[num].read_word = real_read_word;
mb[num].write_word = real_write_word;
mb[num].type = MEMTYPE_RAM;
}
else if (!strncmp ("I", value, strlen (value)))
{
mb[num].read_byte = io_read_byte;
mb[num].write_byte = io_write_byte;
mb[num].read_halfword = io_read_halfword;
mb[num].write_halfword = io_write_halfword;
mb[num].read_word = io_read_word;
mb[num].write_word = io_write_word;
mb[num].type = MEMTYPE_IO;
/*ywc 2005-03-30 */
}
else if (!strncmp ("F", value, strlen (value)))
{
mb[num].read_byte = flash_read_byte;
mb[num].write_byte = flash_write_byte;
mb[num].read_halfword = flash_read_halfword;
mb[num].write_halfword = flash_write_halfword;
mb[num].read_word = flash_read_word;
mb[num].write_word = flash_write_word;
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].write_byte = warn_write_byte;
mb[num].write_halfword = warn_write_halfword;
mb[num].write_word = warn_write_word;
}
}
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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -