summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/cmd_bdinfo.c44
-rw-r--r--common/cmd_bootm.c9
-rw-r--r--common/cmd_fdc.c60
-rw-r--r--common/cmd_ide.c106
-rw-r--r--common/cmd_nvedit.c12
-rw-r--r--common/console.c4
-rw-r--r--common/env_common.c28
-rw-r--r--common/env_nvram.c32
-rw-r--r--common/hwconfig.c74
-rw-r--r--common/main.c9
10 files changed, 107 insertions, 271 deletions
diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c
index a0f7998..710abdf 100644
--- a/common/cmd_bdinfo.c
+++ b/common/cmd_bdinfo.c
@@ -37,8 +37,9 @@ static void print_eth(int idx);
#ifndef CONFIG_ARM /* PowerPC and other */
static void print_lnum(const char *, u64);
+#endif
-#ifdef CONFIG_PPC
+#if defined(CONFIG_PPC)
static void print_str(const char *, const char *);
int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
@@ -119,7 +120,7 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 0;
}
-#elif defined(CONFIG_NIOS2) /* Nios-II */
+#elif defined(CONFIG_NIOS2)
int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
@@ -145,7 +146,8 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 0;
}
-#elif defined(CONFIG_MICROBLAZE) /* ! PPC, which leaves Microblaze */
+
+#elif defined(CONFIG_MICROBLAZE)
int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
@@ -167,7 +169,8 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 0;
}
-#elif defined(CONFIG_SPARC) /* SPARC */
+#elif defined(CONFIG_SPARC)
+
int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
bd_t *bd = gd->bd;
@@ -199,7 +202,8 @@ int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
return 0;
}
-#elif defined(CONFIG_M68K) /* M68K */
+#elif defined(CONFIG_M68K)
+
static void print_str(const char *, const char *);
int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
@@ -249,6 +253,7 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
#elif defined(CONFIG_BLACKFIN)
+
static void print_str(const char *, const char *);
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
@@ -277,7 +282,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 0;
}
-#else /* ! PPC, which leaves MIPS */
+#elif defined(CONFIG_MIPS)
int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
@@ -296,9 +301,28 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 0;
}
-#endif /* MIPS */
-#else /* ARM */
+#elif defined(CONFIG_AVR32)
+
+int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ bd_t *bd = gd->bd;
+
+ print_num ("boot_params", (ulong)bd->bi_boot_params);
+ print_num ("memstart", (ulong)bd->bi_memstart);
+ print_lnum ("memsize", (u64)bd->bi_memsize);
+ print_num ("flashstart", (ulong)bd->bi_flashstart);
+ print_num ("flashsize", (ulong)bd->bi_flashsize);
+ print_num ("flashoffset", (ulong)bd->bi_flashoffset);
+
+ print_eth(0);
+ printf ("ip_addr = %pI4\n", &bd->bi_ip_addr);
+ printf ("baudrate = %lu bps\n", bd->bi_baudrate);
+
+ return 0;
+}
+
+#elif defined(CONFIG_ARM)
int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
@@ -324,7 +348,9 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 0;
}
-#endif /* CONFIG_ARM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
+#else
+ #error "a case for this architecture does not exist!"
+#endif
static void print_num(const char *name, ulong value)
{
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 8803202..74ff205 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -635,15 +635,6 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
usb_stop();
#endif
-#ifdef CONFIG_AMIGAONEG3SE
- /*
- * We've possible left the caches enabled during
- * bios emulation, so turn them off again
- */
- icache_disable();
- dcache_disable();
-#endif
-
ret = bootm_load_os(images.os, &load_end, 1);
if (ret < 0) {
diff --git a/common/cmd_fdc.c b/common/cmd_fdc.c
index 8e18c71..4c16d19 100644
--- a/common/cmd_fdc.c
+++ b/common/cmd_fdc.c
@@ -183,31 +183,6 @@ static FDC_COMMAND_STRUCT cmd; /* global command struct */
#define CONFIG_SYS_ISA_IO_OFFSET 0
#endif
-
-#ifdef CONFIG_AMIGAONEG3SE
-unsigned char INT6_Status;
-
-void fdc_interrupt(void)
-{
- INT6_Status = 0x80;
-}
-
-/* waits for an interrupt (polling) */
-int wait_for_fdc_int(void)
-{
- unsigned long timeout;
- timeout = FDC_TIME_OUT;
- while(((volatile)INT6_Status & 0x80) == 0) {
- timeout--;
- udelay(10);
- if(timeout == 0) /* timeout occured */
- return FALSE;
- }
- INT6_Status = 0;
- return TRUE;
-}
-#endif
-
/* Supporting Functions */
/* reads a Register of the FDC */
unsigned char read_fdc_reg(unsigned int addr)
@@ -230,7 +205,6 @@ void write_fdc_reg(unsigned int addr, unsigned char val)
tmp[0]=val;
}
-#ifndef CONFIG_AMIGAONEG3SE
/* waits for an interrupt (polling) */
int wait_for_fdc_int(void)
{
@@ -245,8 +219,6 @@ int wait_for_fdc_int(void)
return TRUE;
}
-#endif
-
/* reads a byte from the FIFO of the FDC and checks direction and RQM bit
of the MSR. returns -1 if timeout, or byte if ok */
int read_fdc_byte(void)
@@ -438,7 +410,6 @@ int fdc_seek(FDC_COMMAND_STRUCT *pCMD,FD_GEO_STRUCT *pFG)
return(fdc_issue_cmd(pCMD,pFG));
}
-#ifndef CONFIG_AMIGAONEG3SE
/* terminates current command, by not servicing the FIFO
* waits for interrupt and fills in the result bytes */
int fdc_terminate(FDC_COMMAND_STRUCT *pCMD)
@@ -452,27 +423,6 @@ int fdc_terminate(FDC_COMMAND_STRUCT *pCMD)
}
return TRUE;
}
-#endif
-#ifdef CONFIG_AMIGAONEG3SE
-int fdc_terminate(FDC_COMMAND_STRUCT *pCMD)
-{
- int i;
- for(i=0;i<100;i++)
- udelay(500); /* wait 500usec for fifo overrun */
- while((INT6_Status&0x80)==0x00); /* wait as long as no int has occured */
- for(i=0;i<7;i++) {
- pCMD->result[i]=(unsigned char)read_fdc_byte();
- }
- INT6_Status = 0;
- return TRUE;
-}
-
-#endif
-
-#ifdef CONFIG_AMIGAONEG3SE
-#define disable_interrupts() 0
-#define enable_interrupts() (void)0
-#endif
/* reads data from FDC, seek commands are issued automatic */
int fdc_read_data(unsigned char *buffer, unsigned long blocks,FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
@@ -593,11 +543,6 @@ retrycal:
return TRUE;
}
-#ifdef CONFIG_AMIGAONEG3SE
-#undef disable_interrupts()
-#undef enable_interrupts()
-#endif
-
/* Scan all drives and check if drive is present and disk is inserted */
int fdc_check_drive(FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
{
@@ -647,11 +592,6 @@ int fdc_setup(int drive, FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
{
int i;
-#ifdef CONFIG_AMIGAONEG3SE
- irq_install_handler(6, (interrupt_handler_t *)fdc_interrupt, NULL);
- i8259_unmask_irq(6);
-#endif
-
#ifdef CONFIG_SYS_FDC_HW_INIT
fdc_hw_init ();
#endif
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index 093ca9f..8bd8920 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -119,31 +119,22 @@ ulong ide_bus_offset[CONFIG_SYS_IDE_MAXBUS] = {
};
-#ifndef CONFIG_AMIGAONEG3SE
static int ide_bus_ok[CONFIG_SYS_IDE_MAXBUS];
-#else
-static int ide_bus_ok[CONFIG_SYS_IDE_MAXBUS] = {0,};
-#endif
block_dev_desc_t ide_dev_desc[CONFIG_SYS_IDE_MAXDEVICE];
/* ------------------------------------------------------------------------- */
#ifdef CONFIG_IDE_LED
-#if !defined(CONFIG_KUP4K) && !defined(CONFIG_KUP4X) &&!defined(CONFIG_BMS2003) &&!defined(CONFIG_CPC45)
+# if !defined(CONFIG_BMS2003) && \
+ !defined(CONFIG_CPC45) && \
+ !defined(CONFIG_KUP4K) && \
+ !defined(CONFIG_KUP4X)
static void ide_led (uchar led, uchar status);
#else
extern void ide_led (uchar led, uchar status);
#endif
#else
-#ifndef CONFIG_AMIGAONEG3SE
#define ide_led(a,b) /* dummy */
-#else
-extern void ide_led(uchar led, uchar status);
-#define LED_IDE1 1
-#define LED_IDE2 2
-#define CONFIG_IDE_LED 1
-#define DEVICE_LED(x) 1
-#endif
#endif
#ifdef CONFIG_IDE_RESET
@@ -562,13 +553,10 @@ void ide_init (void)
#endif
unsigned char c;
int i, bus;
-#if defined(CONFIG_AMIGAONEG3SE) || defined(CONFIG_SC3)
+#if defined(CONFIG_SC3)
unsigned int ata_reset_time = ATA_RESET_TIME;
char *s;
#endif
-#ifdef CONFIG_AMIGAONEG3SE
- unsigned int max_bus_scan;
-#endif
#ifdef CONFIG_IDE_8xx_PCCARD
extern int pcmcia_on (void);
extern int ide_devices_found; /* Initialized in check_ide_device() */
@@ -638,19 +626,8 @@ void ide_init (void)
* Wait for IDE to get ready.
* According to spec, this can take up to 31 seconds!
*/
-#ifndef CONFIG_AMIGAONEG3SE
for (bus=0; bus<CONFIG_SYS_IDE_MAXBUS; ++bus) {
int dev = bus * (CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS);
-#else
- s = getenv("ide_maxbus");
- if (s)
- max_bus_scan = simple_strtol(s, NULL, 10);
- else
- max_bus_scan = CONFIG_SYS_IDE_MAXBUS;
-
- for (bus=0; bus<max_bus_scan; ++bus) {
- int dev = bus * (CONFIG_SYS_IDE_MAXDEVICE / max_bus_scan);
-#endif
#ifdef CONFIG_IDE_8xx_PCCARD
/* Skip non-ide devices from probing */
@@ -668,30 +645,19 @@ void ide_init (void)
udelay (100000); /* 100 ms */
ide_outb (dev, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(dev));
udelay (100000); /* 100 ms */
-#if defined(CONFIG_AMIGAONEG3SE) || defined(CONFIG_SC3)
- if ((s = getenv("ide_reset_timeout")) != NULL)
- ata_reset_time = simple_strtol(s, NULL, 10);
-#endif
i = 0;
do {
udelay (10000); /* 10 ms */
c = ide_inb (dev, ATA_STATUS);
i++;
-#if defined(CONFIG_AMIGAONEG3SE) || defined(CONFIG_SC3)
+#if defined(CONFIG_SC3)
if (i > (ata_reset_time * 100)) {
#else
if (i > (ATA_RESET_TIME * 100)) {
#endif
puts ("** Timeout **\n");
ide_led ((LED_IDE1 | LED_IDE2), 0); /* LED's off */
-#ifdef CONFIG_AMIGAONEG3SE
- /* If this is the second bus, the first one was OK */
- if (bus != 0) {
- ide_bus_ok[bus] = 0;
- goto skip_bus;
- }
-#endif
return;
}
if ((i >= 100) && ((i%100)==0)) {
@@ -714,9 +680,6 @@ void ide_init (void)
WATCHDOG_RESET();
}
-#ifdef CONFIG_AMIGAONEG3SE
- skip_bus:
-#endif
putc ('\n');
ide_led ((LED_IDE1 | LED_IDE2), 0); /* LED's off */
@@ -1010,10 +973,6 @@ static void ide_ident (block_dev_desc_t *dev_desc)
unsigned char c;
hd_driveid_t *iop = (hd_driveid_t *)iobuf;
-#ifdef CONFIG_AMIGAONEG3SE
- int max_bus_scan;
- char *s;
-#endif
#ifdef CONFIG_ATAPI
int retries = 0;
int do_retry = 0;
@@ -1030,19 +989,6 @@ static void ide_ident (block_dev_desc_t *dev_desc)
device=dev_desc->dev;
printf (" Device %d: ", device);
-#ifdef CONFIG_AMIGAONEG3SE
- s = getenv("ide_maxbus");
- if (s) {
- max_bus_scan = simple_strtol(s, NULL, 10);
- } else {
- max_bus_scan = CONFIG_SYS_IDE_MAXBUS;
- }
- if (device >= max_bus_scan*2) {
- dev_desc->type=DEV_TYPE_UNKNOWN;
- return;
- }
-#endif
-
ide_led (DEVICE_LED(device), 1); /* LED on */
/* Select device
*/
@@ -1086,10 +1032,6 @@ static void ide_ident (block_dev_desc_t *dev_desc)
if (((c & ATA_STAT_DRQ) == 0) ||
((c & (ATA_STAT_FAULT|ATA_STAT_ERR)) != 0) ) {
#ifdef CONFIG_ATAPI
-#ifdef CONFIG_AMIGAONEG3SE
- s = getenv("ide_doreset");
- if (s && strcmp(s, "on") == 0)
-#endif
{
/* Need to soft reset the device in case it's an ATAPI... */
debug ("Retrying...\n");
@@ -1601,7 +1543,6 @@ static void ide_reset (void)
/* ------------------------------------------------------------------------- */
#if defined(CONFIG_IDE_LED) && \
- !defined(CONFIG_AMIGAONEG3SE)&& \
!defined(CONFIG_CPC45) && \
!defined(CONFIG_HMI10) && \
!defined(CONFIG_KUP4K) && \
@@ -1758,9 +1699,6 @@ unsigned char atapi_issue(int device,unsigned char* ccb,int ccblen, unsigned cha
*/
mask = ATA_STAT_BUSY|ATA_STAT_DRQ;
res = 0;
-#ifdef CONFIG_AMIGAONEG3SE
-# warning THF: Removed LBA mode ???
-#endif
ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
c = atapi_wait_mask(device,ATAPI_TIME_OUT,mask,res);
if ((c & mask) != res) {
@@ -1774,9 +1712,6 @@ unsigned char atapi_issue(int device,unsigned char* ccb,int ccblen, unsigned cha
ide_outb (device, ATA_SECT_NUM, 0);
ide_outb (device, ATA_CYL_LOW, (unsigned char)(buflen & 0xFF));
ide_outb (device, ATA_CYL_HIGH, (unsigned char)((buflen>>8) & 0xFF));
-#ifdef CONFIG_AMIGAONEG3SE
-# warning THF: Removed LBA mode ???
-#endif
ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
ide_outb (device, ATA_COMMAND, ATAPI_CMD_PACKET);
@@ -1875,16 +1810,6 @@ unsigned char atapi_issue_autoreq (int device,
unsigned char res,key,asc,ascq;
int notready,unitattn;
-#ifdef CONFIG_AMIGAONEG3SE
- char *s;
- unsigned int timeout, retrycnt;
-
- s = getenv("ide_cd_timeout");
- timeout = s ? (simple_strtol(s, NULL, 10)*1000000)/5 : 0;
-
- retrycnt = 0;
-#endif
-
unitattn=ATAPI_UNIT_ATTN;
notready=ATAPI_DRIVE_NOT_READY;
@@ -1939,25 +1864,6 @@ retry:
goto error;
}
-#ifdef CONFIG_AMIGAONEG3SE
- if ((sense_data[2]&0xF)==0x0B) {
- debug ("ABORTED COMMAND...retry\n");
- if (retrycnt++ < 4)
- goto retry;
- return (0xFF);
- }
-
- if ((sense_data[2]&0xf) == 0x02 &&
- sense_data[12] == 0x04 &&
- sense_data[13] == 0x01 ) {
- debug ("Waiting for unit to become active\n");
- udelay(timeout);
- if (retrycnt++ < 4)
- goto retry;
- return 0xFF;
- }
-#endif /* CONFIG_AMIGAONEG3SE */
-
printf ("ERROR: Unknown Sense key %02X ASC %02X ASCQ %02X\n",key,asc,ascq);
error:
debug ("ERROR Sense key %02X ASC %02X ASCQ %02X\n",key,asc,ascq);
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index eb89e9e..d2ef217 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -385,18 +385,6 @@ int _do_setenv (int flag, int argc, char *argv[])
return 0;
}
#endif
-
-#ifdef CONFIG_AMIGAONEG3SE
- if (strcmp(argv[1], "vga_fg_color") == 0 ||
- strcmp(argv[1], "vga_bg_color") == 0 ) {
- extern void video_set_color(unsigned char attr);
- extern unsigned char video_get_attr(void);
-
- video_set_color(video_get_attr());
- return 0;
- }
-#endif /* CONFIG_AMIGAONEG3SE */
-
return 0;
}
diff --git a/common/console.c b/common/console.c
index 51c6fb6..b09b7d1 100644
--- a/common/console.c
+++ b/common/console.c
@@ -29,10 +29,6 @@
DECLARE_GLOBAL_DATA_PTR;
-#ifdef CONFIG_AMIGAONEG3SE
-int console_changed = 0;
-#endif
-
#ifdef CONFIG_SYS_CONSOLE_IS_IN_ENV
/*
* if overwrite_console returns 1, the stdin, stderr and stdout
diff --git a/common/env_common.c b/common/env_common.c
index 439a4a9..82e4936 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -32,11 +32,6 @@
DECLARE_GLOBAL_DATA_PTR;
-#ifdef CONFIG_AMIGAONEG3SE
- extern void enable_nvram(void);
- extern void disable_nvram(void);
-#endif
-
#undef DEBUG_ENV
#ifdef DEBUG_ENV
#define DEBUGF(fmt,args...) printf(fmt ,##args)
@@ -159,20 +154,6 @@ static uchar env_get_char_init (int index)
return (c);
}
-#ifdef CONFIG_AMIGAONEG3SE
-uchar env_get_char_memory (int index)
-{
- uchar retval;
- enable_nvram();
- if (gd->env_valid) {
- retval = ( *((uchar *)(gd->env_addr + index)) );
- } else {
- retval = ( default_environment[index] );
- }
- disable_nvram();
- return retval;
-}
-#else
uchar env_get_char_memory (int index)
{
if (gd->env_valid) {
@@ -181,7 +162,6 @@ uchar env_get_char_memory (int index)
return ( default_environment[index] );
}
}
-#endif
uchar env_get_char (int index)
{
@@ -229,10 +209,6 @@ void env_relocate (void)
gd->reloc_off);
#endif
-#ifdef CONFIG_AMIGAONEG3SE
- enable_nvram();
-#endif
-
#ifdef ENV_IS_EMBEDDED
/*
* The environment buffer is embedded with the text segment,
@@ -263,10 +239,6 @@ void env_relocate (void)
env_relocate_spec ();
}
gd->env_addr = (ulong)&(env_ptr->data);
-
-#ifdef CONFIG_AMIGAONEG3SE
- disable_nvram();
-#endif
}
#ifdef CONFIG_AUTO_COMPLETE
diff --git a/common/env_nvram.c b/common/env_nvram.c
index 2628fe4..7c7cf98 100644
--- a/common/env_nvram.c
+++ b/common/env_nvram.c
@@ -59,24 +59,6 @@ char * env_name_spec = "NVRAM";
extern uchar default_environment[];
-#ifdef CONFIG_AMIGAONEG3SE
-uchar env_get_char_spec (int index)
-{
-#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
- uchar c;
-
- nvram_read(&c, CONFIG_ENV_ADDR+index, 1);
-
- return c;
-#else
- uchar retval;
- enable_nvram();
- retval = *((uchar *)(gd->env_addr + index));
- disable_nvram();
- return retval;
-#endif
-}
-#else
uchar env_get_char_spec (int index)
{
#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
@@ -89,7 +71,6 @@ uchar env_get_char_spec (int index)
return *((uchar *)(gd->env_addr + index));
#endif
}
-#endif
void env_relocate_spec (void)
{
@@ -103,19 +84,12 @@ void env_relocate_spec (void)
int saveenv (void)
{
int rcode = 0;
-#ifdef CONFIG_AMIGAONEG3SE
- enable_nvram();
-#endif
#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
nvram_write(CONFIG_ENV_ADDR, env_ptr, CONFIG_ENV_SIZE);
#else
if (memcpy ((char *)CONFIG_ENV_ADDR, env_ptr, CONFIG_ENV_SIZE) == NULL)
rcode = 1 ;
#endif
-#ifdef CONFIG_AMIGAONEG3SE
- udelay(10000);
- disable_nvram();
-#endif
return rcode;
}
@@ -127,9 +101,6 @@ int saveenv (void)
*/
int env_init (void)
{
-#ifdef CONFIG_AMIGAONEG3SE
- enable_nvram();
-#endif
#if defined(CONFIG_SYS_NVRAM_ACCESS_ROUTINE)
ulong crc;
uchar data[ENV_SIZE];
@@ -147,8 +118,5 @@ int env_init (void)
gd->env_addr = (ulong)&default_environment[0];
gd->env_valid = 0;
}
-#ifdef CONFIG_AMIGAONEG3SE
- disable_nvram();
-#endif
return (0);
}
diff --git a/common/hwconfig.c b/common/hwconfig.c
index e5c60ba..1f9f4a0 100644
--- a/common/hwconfig.c
+++ b/common/hwconfig.c
@@ -11,15 +11,23 @@
* the License, or (at your option) any later version.
*/
+#ifndef HWCONFIG_TEST
#include <config.h>
#include <common.h>
#include <exports.h>
#include <hwconfig.h>
#include <linux/types.h>
#include <linux/string.h>
+#else
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#define min(a, b) (((a) < (b)) ? (a) : (b))
+#endif /* HWCONFIG_TEST */
static const char *hwconfig_parse(const char *opts, size_t maxlen,
- const char *opt, char stopch, char eqch,
+ const char *opt, char *stopchs, char eqch,
size_t *arglen)
{
size_t optlen = strlen(opt);
@@ -33,8 +41,9 @@ next:
if (end - start > maxlen)
return NULL;
- if (str && (str == opts || str[-1] == stopch) &&
- (*end == stopch || *end == eqch || *end == '\0')) {
+ if (str && (str == opts || strpbrk(str - 1, stopchs) == str - 1) &&
+ (strpbrk(end, stopchs) == end || *end == eqch ||
+ *end == '\0')) {
const char *arg_end;
if (!arglen)
@@ -43,7 +52,7 @@ next:
if (*end != eqch)
return NULL;
- arg_end = strchr(str, stopch);
+ arg_end = strpbrk(str, stopchs);
if (!arg_end)
*arglen = min(maxlen, strlen(str)) - optlen - 1;
else
@@ -66,15 +75,15 @@ static const char *__hwconfig(const char *opt, size_t *arglen)
if (env_hwconfig)
return hwconfig_parse(env_hwconfig, strlen(env_hwconfig),
- opt, ';', ':', arglen);
+ opt, ";", ':', arglen);
if (board_hwconfig)
return hwconfig_parse(board_hwconfig, strlen(board_hwconfig),
- opt, ';', ':', arglen);
+ opt, ";", ':', arglen);
if (cpu_hwconfig)
return hwconfig_parse(cpu_hwconfig, strlen(cpu_hwconfig),
- opt, ';', ':', arglen);
+ opt, ";", ':', arglen);
return NULL;
}
@@ -164,7 +173,7 @@ int hwconfig_sub(const char *opt, const char *subopt)
arg = __hwconfig(opt, &arglen);
if (!arg)
return 0;
- return !!hwconfig_parse(arg, arglen, subopt, ',', '=', NULL);
+ return !!hwconfig_parse(arg, arglen, subopt, ",;", '=', NULL);
}
/*
@@ -185,7 +194,7 @@ const char *hwconfig_subarg(const char *opt, const char *subopt,
arg = __hwconfig(opt, &arglen);
if (!arg)
return NULL;
- return hwconfig_parse(arg, arglen, subopt, ',', '=', subarglen);
+ return hwconfig_parse(arg, arglen, subopt, ",;", '=', subarglen);
}
/*
@@ -208,3 +217,50 @@ int hwconfig_subarg_cmp(const char *opt, const char *subopt, const char *subarg)
return !strncmp(argstr, subarg, arglen);
}
+
+#ifdef HWCONFIG_TEST
+int main()
+{
+ const char *ret;
+ size_t len;
+
+ setenv("hwconfig", "key1:subkey1=value1,subkey2=value2;key2:value3;;;;"
+ "key3;:,:=;key4", 1);
+
+ ret = hwconfig_arg("key1", &len);
+ printf("%zd %.*s\n", len, (int)len, ret);
+ assert(len == 29);
+ assert(hwconfig_arg_cmp("key1", "subkey1=value1,subkey2=value2"));
+ assert(!strncmp(ret, "subkey1=value1,subkey2=value2", len));
+
+ ret = hwconfig_subarg("key1", "subkey1", &len);
+ printf("%zd %.*s\n", len, (int)len, ret);
+ assert(len == 6);
+ assert(hwconfig_subarg_cmp("key1", "subkey1", "value1"));
+ assert(!strncmp(ret, "value1", len));
+
+ ret = hwconfig_subarg("key1", "subkey2", &len);
+ printf("%zd %.*s\n", len, (int)len, ret);
+ assert(len == 6);
+ assert(hwconfig_subarg_cmp("key1", "subkey2", "value2"));
+ assert(!strncmp(ret, "value2", len));
+
+ ret = hwconfig_arg("key2", &len);
+ printf("%zd %.*s\n", len, (int)len, ret);
+ assert(len == 6);
+ assert(hwconfig_arg_cmp("key2", "value3"));
+ assert(!strncmp(ret, "value3", len));
+
+ assert(hwconfig("key3"));
+ assert(hwconfig_arg("key4", &len) == NULL);
+ assert(hwconfig_arg("bogus", &len) == NULL);
+
+ unsetenv("hwconfig");
+
+ assert(hwconfig(NULL) == 0);
+ assert(hwconfig("") == 0);
+ assert(hwconfig("key3") == 0);
+
+ return 0;
+}
+#endif /* HWCONFIG_TEST */
diff --git a/common/main.c b/common/main.c
index f7e7c1c..3760ba3 100644
--- a/common/main.c
+++ b/common/main.c
@@ -427,14 +427,7 @@ void main_loop (void)
}
}
#endif /* CONFIG_MENUKEY */
-#endif /* CONFIG_BOOTDELAY */
-
-#ifdef CONFIG_AMIGAONEG3SE
- {
- extern void video_banner(void);
- video_banner();
- }
-#endif
+#endif /* CONFIG_BOOTDELAY */
/*
* Main Loop for Monitor Command Processing