diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1998-04-27 18:42:04 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1998-04-27 18:42:04 +0000 |
commit | 96d56b36902a1043c5834776411261c26872f4b8 (patch) | |
tree | eda21ba0f0d9dc283c0d152b1eacc21150615d28 /c/src/lib/libbsp/i386/pc386/start | |
parent | Added I386_HAS_BSWAP cpu model feature flag so swap u32 could take (diff) | |
download | rtems-96d56b36902a1043c5834776411261c26872f4b8.tar.bz2 |
Update from Pedro Romano <pmcnr@camoes.rnl.ist.utl.pt>.
Diffstat (limited to '')
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/start/Makefile.in | 19 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/start/start.s | 135 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/startup/bspstart.c | 21 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/startup/ldsegs.s | 37 |
4 files changed, 47 insertions, 165 deletions
diff --git a/c/src/lib/libbsp/i386/pc386/start/Makefile.in b/c/src/lib/libbsp/i386/pc386/start/Makefile.in index 388e25b482..fc1cb6e136 100644 --- a/c/src/lib/libbsp/i386/pc386/start/Makefile.in +++ b/c/src/lib/libbsp/i386/pc386/start/Makefile.in @@ -8,7 +8,7 @@ VPATH = @srcdir@ RTEMS_ROOT = @top_srcdir@ PROJECT_ROOT = @PROJECT_ROOT@ -PGMS=${ARCH}/start.o +PGMS=${ARCH}/start.o ${ARCH}/start16.bin # C source names, if any, go here -- minus the .c C_PIECES= @@ -18,7 +18,7 @@ C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) H_FILES= # Assembly source names, if any, go here -- minus the .s -S_PIECES=start +S_PIECES=start16 start S_FILES=$(S_PIECES:%=%.s) S_O_FILES=$(S_FILES:%.s=${ARCH}/%.o) @@ -50,8 +50,21 @@ LDFLAGS += CLEAN_ADDITIONS += CLOBBER_ADDITIONS += -all: ${ARCH} $(SRCS) $(OBJS) $(PGM) +all: ${ARCH} $(SRCS) $(OBJS) $(PGMS) $(INSTALL_VARIANT) -m 555 ${PGMS} ${PROJECT_RELEASE}/lib # Install the program(s), appending _g or _p as appropriate. # for include files, just use $(INSTALL) + +LINKCMDS=$(srcdir)/../startup/linkcmds + +${ARCH}/start16.o: start16.s + sed -e 's/\/\/.*$$//' < $< | $(CPP) $(ASMFLAGS) -I. -I$(srcdir) \ + -DASM -DSTART32ADDR=$(RELOCADDR) - > $*.i + $(AS) $(ASFLAGS) -o $@ $*.i + +${ARCH}/start16.bin: ${ARCH}/start16.o + $(LD) -N -T $(LINKCMDS) -Ttext $(START16ADDR) -e start16 -nostdlib \ + --oformat=elf32-i386 -o $(basename $@).obj $(basename $@).o + $(OBJCOPY) -O binary $(basename $@).obj $@ + diff --git a/c/src/lib/libbsp/i386/pc386/start/start.s b/c/src/lib/libbsp/i386/pc386/start/start.s index 03ded48d45..9501af12b8 100644 --- a/c/src/lib/libbsp/i386/pc386/start/start.s +++ b/c/src/lib/libbsp/i386/pc386/start/start.s @@ -30,9 +30,6 @@ | * http://www.OARcorp.com/rtems/license.html. | ************************************************************************** | -| Also based on (from the Linux source tree): -| video.S - Copyright (C) 1995, 1996 Martin Mares <mj@k332.feld.cvut.cz> -| | $Id$ +--------------------------------------------------------------------------*/ @@ -40,17 +37,6 @@ #include "asm.h" /*----------------------------------------------------------------------------+ -| Constants -+----------------------------------------------------------------------------*/ - -#ifdef pc386 - -.set PROT_CODE_SEG, 0x08 # offset of code segment descriptor into GDT -.set CR0_PE, 1 # protected mode flag on CR0 register - -#endif /* pc386 */ - -/*----------------------------------------------------------------------------+ | A Descriptor table register has the following format: +----------------------------------------------------------------------------*/ @@ -59,6 +45,13 @@ .set DTR_SIZE, 6 # size of DTR register /*----------------------------------------------------------------------------+ +| Size of heap and stack: ++----------------------------------------------------------------------------*/ + +.set HEAP_SIZE, 0x2000 +.set STACK_SIZE, 0x1000 + +/*----------------------------------------------------------------------------+ | CODE section +----------------------------------------------------------------------------*/ @@ -72,66 +65,10 @@ BEGIN_CODE SYM (start): -/*----------------------------------------------------------------------------+ -| Switch VGA video to 80 lines x 50 columns mode. Has to be done before turning -| protected mode on since it uses BIOS int 10h (video) services. -+----------------------------------------------------------------------------*/ - -#if defined(pc386) && defined(RTEMS_VIDEO_80x50) - -.code16 - - movw $0x0003, ax # forced set - int $0x10 - movw $0x1112, ax # use 8x8 font - xorb %bl, %bl - int $0x10 - movw $0x1201, ax # turn off cursor emulation - movb $0x34, %bl - int $0x10 - movb $0x01, ah # define cursor (scan lines 0 to 7) - movw $0x0007, cx - int $0x10 - -.code32 - -#endif /* pc386 && RTEMS_VIDEO_80x50 */ - nop cli # DISABLE INTERRUPTS!!! /*----------------------------------------------------------------------------+ -| Bare PC machines boot in real mode! We have to turn protected mode on. -+----------------------------------------------------------------------------*/ - -#ifdef pc386 - - data16 - movl $ SYM(gdtptr), eax - data16 - andl $0x0000ffff, eax # get offset into segment - addr16 - lgdt cs:(eax) # load Global Descriptor Table - data16 - movl $ SYM(idtptr), eax - data16 - andl $0x0000ffff, eax # get offset into segment - addr16 - lidt cs:(eax) # load Interrupt Descriptor Table - - movl %cr0, eax - data16 - orl $CR0_PE, eax - movl eax, %cr0 # turn on protected mode - - data16 - ljmp $PROT_CODE_SEG, $ SYM(next) # flush prefetch queue - -SYM(next): - -#endif /* pc386 */ - -/*----------------------------------------------------------------------------+ | Load the segment registers (this is done by the board's BSP) and perform any | other board specific initialization procedures. | @@ -149,9 +86,9 @@ SYM(next): SYM (_establish_stack): movl $_end, eax # eax = end of bss/start of heap - addl $heap_size, eax # eax = end of heap + addl $HEAP_SIZE, eax # eax = end of heap movl eax, stack_start # Save for brk() routine - addl $stack_size, eax # make room for stack + addl $STACK_SIZE, eax # make room for stack andl $0xffffffc0, eax # align it on 16 byte boundary movl eax, esp # set stack pointer movl eax, ebp # set base pointer @@ -262,6 +199,7 @@ SYM (no_gdt_load): cmpb $0, SYM (_Do_Load_IDT) # Should the new IDT be loaded? je SYM (no_idt_load) # NO, then branch lidt SYM (_New_IDTR) # load the new IDT + SYM (no_idt_load): /*---------------------------------------------------------------------+ @@ -315,41 +253,6 @@ END_CODE BEGIN_DATA -#ifdef pc386 - -/************************** -* GLOBAL DESCRIPTOR TABLE * -**************************/ - - .align 4 -SYM(gdtptr): - /* we use the NULL descriptor to store the GDT pointer - a trick quite - nifty due to: Robert Collins (rcollins@x86.org) */ - .word gdtlen - 1 - .long gdtptr - .word 0x0000 - - /* code segment */ - .word 0xffff, 0 - .byte 0, 0x9f, 0xcf, 0 - - /* data segment */ - .word 0xffff, 0 - .byte 0, 0x93, 0xcf, 0 - - .set gdtlen, . - gdtptr # length of GDT - -/************************************* -* INTERRUPT DESCRIPTOR TABLE POINTER * -*************************************/ - - .align 4 -SYM(idtptr): - .word 0x07ff # limit at maximum (allows all 256 interrupts) - .word 0, 0 # base at 0 - -#endif /* pc386 */ - EXTERN (Do_Load_IDT) # defined in the BSP EXTERN (Do_Load_GDT) # defined in the BSP @@ -370,11 +273,13 @@ END_DATA BEGIN_BSS - PUBLIC (heap_size) - .set heap_size, 0x2000 + PUBLIC (_heap_size) +SYM (_heap_size): + .long HEAP_SIZE - PUBLIC (stack_size) - .set stack_size, 0x1000 + PUBLIC (_stack_size) +SYM (_stack_size): + .long STACK_SIZE PUBLIC (Interrupt_descriptor_table) SYM (Interrupt_descriptor_table): @@ -390,14 +295,8 @@ SYM (_New_IDTR): PUBLIC (_Global_descriptor_table) SYM (_Global_descriptor_table): -#ifdef pc386 - .space (3 * 8) # the PC386 bsp only needs 3 segment descriptors: -#else # NULL, CODE and DATA - .space (8192 * 8) - -#endif /* pc386 */ - + # NULL, CODE and DATA PUBLIC (_Original_GDTR) SYM (_Original_GDTR): .space DTR_SIZE diff --git a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c index 305545dee0..370b7487d7 100644 --- a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c +++ b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c @@ -41,16 +41,13 @@ /*-------------------------------------------------------------------------+ | Global Variables +--------------------------------------------------------------------------*/ -#ifdef RTEMS_SMALL_MEMORY extern rtems_unsigned32 _end; /* End of BSS. Defined in 'linkcmds'. */ +extern rtems_unsigned32 _heap_size; /* Size of stack. Defined in 'start.s'. */ +extern rtems_unsigned32 _stack_size; /* Size of heap. Defined in 'start.s'. */ -rtems_unsigned32 rtemsFreeMemStart = (rtems_unsigned32)&_end; +rtems_unsigned32 rtemsFreeMemStart; /* Address of start of free memory - should be updated after creating new partitions or regions. */ -#else -rtems_unsigned32 rtemsFreeMemStart = RAM_START; - /* RAM_START defined in 'bsp.h'. */ -#endif /* RTEMS_SMALL_MEMORY */ /* The original BSP configuration table from the application and our copy of it with some changes. */ @@ -105,6 +102,9 @@ void bsp_pretasking_hook(void) +--------------------------------------------------------------------------*/ void bsp_start( void ) { + rtemsFreeMemStart = (rtems_unsigned32)&_end + _heap_size + _stack_size; + /* set the value of start of free memory. */ + /* If we don't have command line arguments set default program name. */ Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ @@ -118,8 +118,11 @@ void bsp_start( void ) Cpu_table.interrupt_stack_size = 4096; Cpu_table.extra_mpci_receive_server_stack = 0; - /* Place RTEMS workspace at top of physical RAM (RAM_END defined in 'bsp.h' */ + /* Place RTEMS workspace at beginning of free memory. */ + + if (rtemsFreeMemStart & (CPU_ALIGNMENT - 1)) /* not aligned => align it */ + rtemsFreeMemStart = (rtemsFreeMemStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); - BSP_Configuration.work_space_start = - (void *)(RAM_END - BSP_Configuration.work_space_size); + BSP_Configuration.work_space_start = (void *)rtemsFreeMemStart; + rtemsFreeMemStart += BSP_Configuration.work_space_size; } /* bsp_start */ diff --git a/c/src/lib/libbsp/i386/pc386/startup/ldsegs.s b/c/src/lib/libbsp/i386/pc386/startup/ldsegs.s index 2aba236d21..16f791830a 100644 --- a/c/src/lib/libbsp/i386/pc386/startup/ldsegs.s +++ b/c/src/lib/libbsp/i386/pc386/startup/ldsegs.s @@ -69,27 +69,6 @@ BEGIN_CODE EXTERN (establish_stack) /*----------------------------------------------------------------------------+ -| empty_8042 -+------------------------------------------------------------------------------ -| This routine checks that the keyboard command queue is empty (after emptying -| the output buffers). -| No timeout is used - if this hangs there is something wrong with the machine, -| and we probably couldn't proceed anyway. -+----------------------------------------------------------------------------*/ -SYM(empty_8042): - call delay - inb $0x64, al # 8042 status port - testb $0x01, al # output buffer? - jz SYM(no_output) - call SYM(delay) - in $0x60, al # read it - jmp SYM(empty_8042) -SYM(no_output): - test $0x02, al # is input buffer full? - jnz SYM(empty_8042) # yes - loop - ret - -/*----------------------------------------------------------------------------+ | delay +------------------------------------------------------------------------------ | Delay is needed after doing I/O. We do it by writing to a non-existent port. @@ -100,8 +79,8 @@ SYM(delay): /*-------------------------------------------------------------------------+ | Function: _load_segments -| Description: Load board segment registers with apropriate values + enable - A20 line + reprogram PIC. +| Description: Load board segment registers with apropriate values + +| reprogram PIC. | Global Variables: None. | Arguments: None. | Returns: Nothing. @@ -116,18 +95,6 @@ SYM (_load_segments): LOAD_SEGMENTS(RESET_GS, gs) /*---------------------------------------------------------------------+ - | we have to enable A20 in order to access memory above 1MByte - +---------------------------------------------------------------------*/ - - call SYM(empty_8042) - movb $0xD1, al # command write - outb al, $0x64 - call SYM(empty_8042) - movb $0xDF, al # A20 on - outb al, $0x60 - call SYM(empty_8042) - - /*---------------------------------------------------------------------+ | Now we have to reprogram the interrupts :-(. We put them right after | the intel-reserved hardware interrupts, at int 0x20-0x2F. There they | won't mess up anything. Sadly IBM really messed this up with the |