diff options
author | Chris Johns <chrisj@rtems.org> | 2009-04-28 06:20:35 +0000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2009-04-28 06:20:35 +0000 |
commit | 1c5ebc542167a74791cf5e82845e00b4f8ff6330 (patch) | |
tree | e0b839e0a1ef204877767c7d0b9b1f90b1f45a2e /c | |
parent | 2009-04-28 Chris Johns <chrisj@rtems.org> (diff) | |
download | rtems-1c5ebc542167a74791cf5e82845e00b4f8ff6330.tar.bz2 |
2009-04-28 Chris Johns <chrisj@rtems.org>
* Makefile.am: Add bspcmdline.c.
* include/bsp.h: Add boot command line interfaces.
* start/start.c: Save the multiboot command line. Pass the command
line to boot_card.
* start/start.S: Update for boot_card command line change.
* startup/bspstart.c: Initialise the command line.
* startup/bspcmdline.c: New.
* console/console.c, ide/idecfg.c: Add boot command line support.
Diffstat (limited to 'c')
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/ChangeLog | 12 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/Makefile.am | 4 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/console/console.c | 27 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/ide/ide.c | 88 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/ide/idecfg.c | 78 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/include/bsp.h | 11 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/start/start.S | 69 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/startup/bspcmdline.c | 62 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/startup/bspstart.c | 3 |
9 files changed, 309 insertions, 45 deletions
diff --git a/c/src/lib/libbsp/i386/pc386/ChangeLog b/c/src/lib/libbsp/i386/pc386/ChangeLog index 214addfeb0..f6121c2c56 100644 --- a/c/src/lib/libbsp/i386/pc386/ChangeLog +++ b/c/src/lib/libbsp/i386/pc386/ChangeLog @@ -1,3 +1,15 @@ +2009-04-28 Chris Johns <chrisj@rtems.org> + + * Makefile.am: Add bspcmdline.c. + * include/bsp.h: Add boot command line interfaces. + * start/start.c: Save the multiboot command line. Pass the command + line to boot_card. + * start/start.S: Update for boot_card command line change. + * startup/bspstart.c: Initialise the command line. + * startup/bspcmdline.c: New. + * console/console.c, ide/idecfg.c: Add boot command line support. + * ide/ide.cfg: Add prints for errors to help resolve problems. + 2009-02-11 Joel Sherrill <joel.sherrill@oarcorp.com> * configure.ac, start/start16.S: Remove duplicate configure option and diff --git a/c/src/lib/libbsp/i386/pc386/Makefile.am b/c/src/lib/libbsp/i386/pc386/Makefile.am index 70cf8b577d..7ebc164a67 100644 --- a/c/src/lib/libbsp/i386/pc386/Makefile.am +++ b/c/src/lib/libbsp/i386/pc386/Makefile.am @@ -89,10 +89,10 @@ include_HEADERS += ../../i386/shared/comm/uart.h # startup libbsp_a_SOURCES += ../../shared/bsplibc.c ../../shared/bsppost.c \ ../../shared/bsppredriverhook.c startup/bspgetworkarea.c \ - ../../shared/bsppretaskinghook.c startup/bspstart.c \ + ../../shared/bsppretaskinghook.c startup/bspstart.c startup/bspcmdline.c \ ../../shared/bspclean.c startup/bspreset.c ../../i386/shared/irq/idt.c \ ../../i386/shared/irq/irq.c ../../i386/shared/irq/irq_init.c \ - ../../shared/bootcard.c ../../shared/sbrk.c \ + ../../shared/bootcard.c ../../shared/bspinit.c ../../shared/sbrk.c \ startup/ldsegs.S ../../i386/shared/irq/irq_asm.S # timer diff --git a/c/src/lib/libbsp/i386/pc386/console/console.c b/c/src/lib/libbsp/i386/pc386/console/console.c index 126b0cb50b..037f56c859 100644 --- a/c/src/lib/libbsp/i386/pc386/console/console.c +++ b/c/src/lib/libbsp/i386/pc386/console/console.c @@ -149,7 +149,34 @@ console_initialize(rtems_device_major_number major, void *arg) { rtems_status_code status; + const char* mode; + + /* + * Check the command line for the type of mode + * the consol is. + */ + mode = bsp_cmdline_arg ("--console="); + if (mode) + { + mode += sizeof ("--console=") - 1; + if (strncmp (mode, "console", sizeof ("console") - 1) == 0) + { + BSPConsolePort = BSP_CONSOLE_PORT_CONSOLE; + BSPPrintkPort = BSP_CONSOLE_PORT_CONSOLE; + } + else if (strncmp (mode, "com1", sizeof ("com1") - 1) == 0) + { + BSPConsolePort = BSP_UART_COM1; + BSPPrintkPort = BSP_UART_COM1; + } + else if (strncmp (mode, "com2", sizeof ("com2") - 1) == 0) + { + BSPConsolePort = BSP_UART_COM2; + BSPPrintkPort = BSP_UART_COM2; + } + } + /* Initialize the KBD interface */ kbd_init(); diff --git a/c/src/lib/libbsp/i386/pc386/ide/ide.c b/c/src/lib/libbsp/i386/pc386/ide/ide.c index eedd6d34c7..c14598a452 100644 --- a/c/src/lib/libbsp/i386/pc386/ide/ide.c +++ b/c/src/lib/libbsp/i386/pc386/ide/ide.c @@ -30,6 +30,51 @@ #include <libchip/ide_ctrl_io.h> /* #define DEBUG_OUT */ + +static bool pc386_ide_status_busy (uint32_t port, + uint32_t timeout, + uint8_t* status_val) +{ + do + { + inport_byte (port + IDE_REGISTER_STATUS, *status_val); + if ((*status_val & IDE_REGISTER_STATUS_BSY) == 0) + return true; + + if (timeout) + { + timeout--; + rtems_task_wake_after (TOD_MICROSECONDS_TO_TICKS (1000)); + } + } + while (timeout); + + return false; +} + +static bool pc386_ide_status_data_ready (uint32_t port, + uint32_t timeout, + uint8_t* status_val) +{ + do + { + inport_byte (port + IDE_REGISTER_STATUS, *status_val); + + if (((*status_val & IDE_REGISTER_STATUS_BSY) == 0) && + (*status_val & IDE_REGISTER_STATUS_DRQ)) + return true; + + if (timeout) + { + timeout--; + rtems_task_wake_after (TOD_MICROSECONDS_TO_TICKS (1000)); + } + } + while (timeout); + + return false; +} + /* * support functions for IDE harddisk IF */ @@ -174,18 +219,28 @@ void pc386_ide_read_block uint32_t port = IDE_Controller_Table[minor].port1; uint16_t cnt = 0; uint32_t llength = bufs[(*cbuf)].length; - uint8_t status_val; + uint8_t status_val; uint16_t *lbuf = (uint16_t*) ((uint8_t*)(bufs[(*cbuf)].buffer) + (*pos)); - inport_byte(port+IDE_REGISTER_STATUS,status_val); - while ((status_val & IDE_REGISTER_STATUS_DRQ) && - (cnt < block_size)) { + while (cnt < block_size) + { + if (!pc386_ide_status_data_ready (port, 100, &status_val)) + { + printk ("pc386_ide_read_block: status=%02x, cnt=%d bs=%d\n", status_val, cnt, block_size); + /* FIXME: add an error here. */ + return; + } + + if (status_val & IDE_REGISTER_STATUS_ERR) + printk("pc386_ide_read_block: error: %02x\n", status_val); + inport_word(port+IDE_REGISTER_DATA,*lbuf); #ifdef DEBUG_OUT printk("0x%x ",*lbuf); #endif + lbuf++; cnt += sizeof(*lbuf); (*pos) += sizeof(*lbuf); @@ -195,11 +250,7 @@ void pc386_ide_read_block lbuf = bufs[(*cbuf)].buffer; llength = bufs[(*cbuf)].length; } - inport_byte(port+IDE_REGISTER_STATUS,status_val); } -#ifdef DEBUG_OUT - printk("pc386_ide_read_block()\r\n"); -#endif } /*=========================================================================*\ @@ -230,13 +281,23 @@ void pc386_ide_write_block uint8_t status_val; uint16_t *lbuf = (uint16_t*) ((uint8_t*)(bufs[(*cbuf)].buffer) + (*pos)); - + #ifdef DEBUG_OUT - printk("pc386_ide_write_block()\r\n"); + printk("pc386_ide_write_block()\n"); #endif - inport_byte(port+IDE_REGISTER_STATUS,status_val); - while ((status_val & IDE_REGISTER_STATUS_DRQ) && - (cnt < block_size)) { + + while (cnt < block_size) + { + if (!pc386_ide_status_data_ready (port, 100, &status_val)) + { + printk ("pc386_ide_write_block: status=%02x, cnt=%d bs=%d\n", status_val, cnt, block_size); + /* FIXME: add an error here. */ + return; + } + + if (status_val & IDE_REGISTER_STATUS_ERR) + printk("pc386_ide_write_block: error: %02x\n", status_val); + #ifdef DEBUG_OUT printk("0x%x ",*lbuf); #endif @@ -250,7 +311,6 @@ void pc386_ide_write_block lbuf = bufs[(*cbuf)].buffer; llength = bufs[(*cbuf)].length; } - inport_byte(port+IDE_REGISTER_STATUS,status_val); } } diff --git a/c/src/lib/libbsp/i386/pc386/ide/idecfg.c b/c/src/lib/libbsp/i386/pc386/ide/idecfg.c index b06682c299..8569d40eff 100644 --- a/c/src/lib/libbsp/i386/pc386/ide/idecfg.c +++ b/c/src/lib/libbsp/i386/pc386/ide/idecfg.c @@ -35,7 +35,6 @@ extern ide_ctrl_fns_t pc386_ide_ctrl_fns; /* IDE controllers Table */ ide_controller_bsp_table_t IDE_Controller_Table[] = { -#if IDE_USE_PRIMARY_INTERFACE {"/dev/ide0", IDE_STD, /* standard IDE controller */ &pc386_ide_ctrl_fns, @@ -45,11 +44,7 @@ ide_controller_bsp_table_t IDE_Controller_Table[] = { FALSE,0, /* not (yet) interrupt driven */ NULL } -#if IDE_USE_SECONDARY_INTERFACE , /* colon only needed when both interfaces present */ -#endif -#endif -#if IDE_USE_SECONDARY_INTERFACE {"/dev/ide1", IDE_STD, /* standard IDE controller */ &pc386_ide_ctrl_fns, @@ -59,9 +54,74 @@ ide_controller_bsp_table_t IDE_Controller_Table[] = { FALSE,0, /* not (yet) interrupt driven */ NULL } -#endif }; -/* Number of rows in IDE_Controller_Table */ -unsigned long IDE_Controller_Count = - sizeof(IDE_Controller_Table)/sizeof(IDE_Controller_Table[0]); +/* Number of rows in IDE_Controller_Table. Default is 0. */ +unsigned long IDE_Controller_Count; + +#if IDE_USE_PRIMARY_INTERFACE +#define IDE1_DEFAULT true +#else +#define IDE1_DEFAULT false +#endif +#if IDE_USE_SECONDARY_INTERFACE +#define IDE2_DEFAULT true +#else +#define IDE2_DEFAULT false +#endif + +void bsp_ide_cmdline_init(void) +{ + bool ide1 = IDE1_DEFAULT; + bool ide2 = IDE2_DEFAULT; + const char* ide; + + /* + * Can have: + * --ide=1,2 + */ + ide = bsp_cmdline_arg ("--ide="); + + if (ide) + { + int i; + /* + * If a command line option exists remove the defaults. + */ + ide1 = ide2 = false; + + ide += sizeof ("--ide=") - 1; + + for (i = 0; i < 3; i++) + { + switch (ide[i]) + { + case '1': + ide1 = true; + break; + case '2': + ide2 = true; + break; + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ',': + break; + default: + break; + } + } + } + + if (ide2 && !ide1) + IDE_Controller_Table[0] = IDE_Controller_Table[1]; + + if (ide1) + IDE_Controller_Count++; + if (ide2) + IDE_Controller_Count++; +} diff --git a/c/src/lib/libbsp/i386/pc386/include/bsp.h b/c/src/lib/libbsp/i386/pc386/include/bsp.h index a3b484f04a..0df6e9067e 100644 --- a/c/src/lib/libbsp/i386/pc386/include/bsp.h +++ b/c/src/lib/libbsp/i386/pc386/include/bsp.h @@ -183,6 +183,17 @@ void Wait_X_ms(unsigned int timeToWait); /* from 'timer.c' */ #define BSP_CONSOLE_PORT_COM2 (BSP_UART_COM2) /* + * Command line. + */ +const char* bsp_cmdline(void); +const char* bsp_cmdline_arg(const char* arg); + +/* + * IDE command line parsing. + */ +void bsp_ide_cmdline_init(void); + +/* * indicate, that BSP has IDE driver */ #define RTEMS_BSP_HAS_IDE_DRIVER diff --git a/c/src/lib/libbsp/i386/pc386/start/start.S b/c/src/lib/libbsp/i386/pc386/start/start.S index 5dcfdd9e03..373c2d7658 100644 --- a/c/src/lib/libbsp/i386/pc386/start/start.S +++ b/c/src/lib/libbsp/i386/pc386/start/start.S @@ -88,21 +88,42 @@ speakl: jmp speakl # and SPIN!!! cli # DISABLE INTERRUPTS!!! cld - /* Save multiboot info */ - cmp $0x2badb002,eax - jne 1f - /* We have multiboot info; let's hope DS and ES are OK... */ - movl ebx, SYM(_boot_multiboot_info_p) - /* Check for memory size info and save */ - movl ebx, esi - movl $SYM(_boot_multiboot_info), edi - movsd - /* only save flag 1 since that's the only data we save */ - and $1,-4(edi) - je 1f - movl $2,ecx - rep movsd -1: + /* Save multiboot info if we detect a multiboot loader */ + cmp $0x2badb002,eax + jne 2f + + /* We have multiboot info; let's hope DS and ES are OK... */ + movl ebx, SYM(_boot_multiboot_info_p) + /* Check for memory size info and save */ + movl ebx, esi + movl (esi), eax + movl eax, ebx + movl $SYM(_boot_multiboot_info), edi + /* save flags, always present */ + movsd + /* flag 1 is memory */ + and $1, eax + je 1f + movl $2, ecx + rep movsd + /* flag 2 is the command line */ +1: movl ebx, eax + and $4, eax + je 3f + movl (_boot_multiboot_info_p), eax + movl 16(eax), esi + movl $255, ecx +2: movzbl (esi), eax + test al, al + je 3f + movb al, (edi) + inc edi + inc esi + dec ecx + je 3f + jmp 2b +3: xor al, al + movb al, (edi) #ifdef DEBUG_EARLY_START /* * Must get video attribute to have a working printk. @@ -178,11 +199,10 @@ SYM (zero_bss): | Transfer control to User's Board Support Package +---------------------------------------------------------------------*/ - pushl $0 # environp - pushl $0 # argv - pushl $0 # argc + movl $SYM(_boot_multiboot_cmdline), eax + pushl eax # cmdline call SYM (boot_card) - addl $12, esp + addl $4, esp /*---------------------------------------------------------------------+ | Clean up - we do not know anything about it, so we will @@ -199,11 +219,20 @@ SYM(_boot_multiboot_info_p): .long 0 PUBLIC(_boot_multiboot_info) + PUBLIC(_boot_multiboot_flags) + PUBLIC(_boot_multiboot_memory) + PUBLIC(_boot_multiboot_cmdline) SYM(_boot_multiboot_info): +SYM(_boot_multiboot_flags): .long 0 /* flags */ +SYM(_boot_multiboot_memory): .long 0 /* mem_lower */ .long 0 /* mem_upper */ - +SYM(_boot_multiboot_cmdline): + .rept 256 /* cmd line */ + .byte 0 + .endr + PUBLIC(_stack_size) SYM(_stack_size): .long STACK_SIZE diff --git a/c/src/lib/libbsp/i386/pc386/startup/bspcmdline.c b/c/src/lib/libbsp/i386/pc386/startup/bspcmdline.c new file mode 100644 index 0000000000..29b3df7a7b --- /dev/null +++ b/c/src/lib/libbsp/i386/pc386/startup/bspcmdline.c @@ -0,0 +1,62 @@ +/*-------------------------------------------------------------------------+ +| This file contains the PC386 BSP startup package. It includes application, +| board, and monitor specific initialization and configuration. The generic CPU +| dependent initialization has been performed before this routine is invoked. ++--------------------------------------------------------------------------+ +| (C) Copyright 2009 RTEMS Project +| Chris Johns (chrisj@rtems.org) ++--------------------------------------------------------------------------+ +| Disclaimer: +| +| This file is provided "AS IS" without warranty of any kind, either +| expressed or implied. ++--------------------------------------------------------------------------+ +| This code is based on: +| common sense +| With the following copyright notice: +| ************************************************************************** +| * COPYRIGHT (c) 1989-2008. +| * On-Line Applications Research Corporation (OAR). +| * +| * The license and distribution terms for this file may be +| * found in found in the file LICENSE in this distribution or at +| * http://www.rtems.com/license/LICENSE. +| ************************************************************************** +| +| $Id$ ++--------------------------------------------------------------------------*/ + +#include <bsp.h> +#include <rtems/pci.h> +#include <libcpu/cpuModel.h> + +/* + * External data + */ +extern uint32_t _boot_multiboot_flags; +extern uint32_t _boot_multiboot_memory[2]; +extern const char _boot_multiboot_cmdline[256]; + +/*-------------------------------------------------------------------------+ +| Function: bsp_cmdline +| Description: Call when you want the command line. +| Global Variables: The multiboot values copied from the loader. +| Arguments: None. +| Returns: The whole command line. ++--------------------------------------------------------------------------*/ +const char* bsp_cmdline( void ) +{ + return _boot_multiboot_cmdline; +} + +/*-------------------------------------------------------------------------+ +| Function: bsp_cmdline_arg +| Description: Call to search for an argument. +| Global Variables: The multiboot values copied from the loader. +| Arguments: The option start. +| Returns: The option if found or nothing. ++--------------------------------------------------------------------------*/ +const char* bsp_cmdline_arg( const char* arg ) +{ + return strstr (bsp_cmdline (), arg); +} diff --git a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c index 3d87a1cf7d..cdbdd42fae 100644 --- a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c +++ b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c @@ -78,6 +78,9 @@ void bsp_start_default( void ) if (pci_init_retval != PCIB_ERR_SUCCESS) { printk("PCI bus: could not initialize PCI BIOS interface\n"); } + + bsp_ide_cmdline_init (); + } /* bsp_start */ /* |