forked from Imagelibrary/rtems
Patch from Erik Ivanenko <erik.ivanenko@utoronto.ca> to fix some
reported bugs in the start code.
This commit is contained in:
@@ -35,10 +35,12 @@ changes:
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "asm.h"
|
#include "asm.h"
|
||||||
#include "macros.inc"
|
#include "macros.inc"
|
||||||
#include "80386ex.inc"
|
#include "80386ex.inc"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NEW_GAS Needed for binutils 2.9.1.0.7 and higher
|
* NEW_GAS Needed for binutils 2.9.1.0.7 and higher
|
||||||
*/
|
*/
|
||||||
@@ -49,7 +51,7 @@ changes:
|
|||||||
|
|
||||||
PUBLIC (Interrupt_descriptor_table)
|
PUBLIC (Interrupt_descriptor_table)
|
||||||
PUBLIC ( SYM(IDTR) )
|
PUBLIC ( SYM(IDTR) )
|
||||||
PUBLIC( SYM(_initInternalRegisters) )
|
/* PUBLIC( SYM(_initInternalRegisters) ) */
|
||||||
|
|
||||||
BEGIN_DATA
|
BEGIN_DATA
|
||||||
SYM(IDTR): DESC3( SYM(Interrupt_descriptor_table), 0x07ff );
|
SYM(IDTR): DESC3( SYM(Interrupt_descriptor_table), 0x07ff );
|
||||||
@@ -80,39 +82,40 @@ END_DATA
|
|||||||
correct vector offsets. It is for symbol definition only.
|
correct vector offsets. It is for symbol definition only.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
.code16
|
||||||
.section .reset
|
.section .reset
|
||||||
|
|
||||||
PUBLIC ( SYM(reset) )
|
PUBLIC ( SYM(reset) )
|
||||||
SYM(reset):
|
SYM(reset):
|
||||||
nop
|
nop
|
||||||
cli
|
cli
|
||||||
jmp SYM(_initInternalRegisters) /* different section in this file */
|
jmp SYM(_initInternalRegisters) /* different section in this file */
|
||||||
.code32 /* in case this section moves */
|
/* .code32 in case this section moves */
|
||||||
nop /* required by CHIP LAB to pad out size */
|
nop /* required by CHIP LAB to pad out size */
|
||||||
nop
|
nop
|
||||||
nop
|
nop
|
||||||
nop
|
nop
|
||||||
nop
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
|
||||||
.section .initial
|
.section .initial
|
||||||
nop /* nops required to correct 32 bit jmp relative */
|
/* nop */ /* required for linker -- initial jump is to "label - 2" */
|
||||||
nop /* offset from .reset section */
|
/* nop */ /* ie. _initInternalRegisters -2 ( which now == .initial ) */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enable access to peripheral register at expanded I/O addresses
|
* Enable access to peripheral register at expanded I/O addresses
|
||||||
*/
|
*/
|
||||||
SYM(_initInternalRegisters):
|
SYM(_initInternalRegisters):
|
||||||
.code16
|
|
||||||
|
/* .code16 */
|
||||||
movw $0x8000 , ax
|
movw $0x8000 , ax
|
||||||
outb al , $REMAPCFGH
|
outb al , $REMAPCFGH
|
||||||
xchg al , ah
|
xchg al , ah
|
||||||
outb al,$REMAPCFGL
|
outb al,$REMAPCFGL
|
||||||
outw ax, $REMAPCFG ;
|
outw ax, $REMAPCFG ;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configure operation of the A20 Address Line
|
* Configure operation of the A20 Address Line
|
||||||
*/
|
*/
|
||||||
@@ -124,6 +127,7 @@ SYM(A20):
|
|||||||
orb $0x02 , al # Bit 1 Fast A20 = 0 (always 0) else enabled.
|
orb $0x02 , al # Bit 1 Fast A20 = 0 (always 0) else enabled.
|
||||||
outb al , dx
|
outb al , dx
|
||||||
|
|
||||||
|
|
||||||
SYM(Watchdog):
|
SYM(Watchdog):
|
||||||
movw $WDTSTATUS , dx # address the WDT status port
|
movw $WDTSTATUS , dx # address the WDT status port
|
||||||
inb dx , al # get the WDT status
|
inb dx , al # get the WDT status
|
||||||
@@ -242,7 +246,7 @@ SYM(InitSIO):
|
|||||||
SetExRegByte( SIOCFG, 0xC3 ) # SIOn clocked internally
|
SetExRegByte( SIOCFG, 0xC3 ) # SIOn clocked internally
|
||||||
|
|
||||||
SetExRegByte( LCR0, 0x80 ) # latch DLL0, DLH0
|
SetExRegByte( LCR0, 0x80 ) # latch DLL0, DLH0
|
||||||
SetExRegByte( DLL0, 0x51 ) # 0x51 sets to 9600 baud 0x7 -> 115,200
|
SetExRegByte( DLL0, 0x51 ) # 0x51 sets to 9600 baud, 0x28=19.2k, 0x7 -> 115.2k
|
||||||
SetExRegByte( DLH0, 0x00 ) # 0x145 is 2400 baud
|
SetExRegByte( DLH0, 0x00 ) # 0x145 is 2400 baud
|
||||||
SetExRegByte( LCR0, 0x03 ) # enable r/w buffers, IER0 accessible
|
SetExRegByte( LCR0, 0x03 ) # enable r/w buffers, IER0 accessible
|
||||||
# mode 8-n-1
|
# mode 8-n-1
|
||||||
@@ -310,6 +314,14 @@ SYM(InitTimer):
|
|||||||
SYM(InitInt):
|
SYM(InitInt):
|
||||||
|
|
||||||
cli # !
|
cli # !
|
||||||
|
/* SetExRegByte(OCW3S, 0x20) # address the Slave status port
|
||||||
|
movw $OCW3S , dx
|
||||||
|
inb dx , al # Read the IRR.
|
||||||
|
|
||||||
|
SetExRegByte(OCW3M, 0x20) # address the Master status port
|
||||||
|
movw $OCW3M , dx
|
||||||
|
inb dx , al # Read the IRR.
|
||||||
|
*/
|
||||||
|
|
||||||
SetExRegByte(ICW1S , 0x11 ) # EDGE TRIGGERED
|
SetExRegByte(ICW1S , 0x11 ) # EDGE TRIGGERED
|
||||||
SetExRegByte(ICW2S , 0x28 ) # Slave base vector after Master
|
SetExRegByte(ICW2S , 0x28 ) # Slave base vector after Master
|
||||||
@@ -319,21 +331,13 @@ SYM(InitInt):
|
|||||||
SetExRegByte(ICW1M , 0x11 ) # edge triggered
|
SetExRegByte(ICW1M , 0x11 ) # edge triggered
|
||||||
SetExRegByte(ICW2M , 0x20 ) # base vector starts at byte 32
|
SetExRegByte(ICW2M , 0x20 ) # base vector starts at byte 32
|
||||||
SetExRegByte(ICW3M , 0x04) # IR2 is cascaded internally
|
SetExRegByte(ICW3M , 0x04) # IR2 is cascaded internally
|
||||||
SetExRegByte(ICW4M , 0x01 ) # idem
|
SetExRegByte(ICW4M , 0x01 ) # fully nested mode
|
||||||
|
|
||||||
SetExRegByte(OCW1M , 0xde ) # IR0 only = 0xfe. for IR5 and IR0 active use 0xde
|
SetExRegByte(OCW1M , 0xde ) # IR0 only = 0xfe.
|
||||||
|
# for IR5 and IR0 active use 0xde
|
||||||
|
# for IR0 and IR2 use 0xfa
|
||||||
SetExRegByte(INTCFG , 0x00 )
|
SetExRegByte(INTCFG , 0x00 )
|
||||||
|
|
||||||
/*
|
|
||||||
* The addr32 override should ensure that the address for
|
|
||||||
* i8259s_cache is put in 32-bit address space.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(NEW_GAS)
|
|
||||||
addr32 movw $0xFFFB, SYM(i8259s_cache) # set up same values in cache
|
|
||||||
#else
|
|
||||||
movw $0xFFFB, SYM(i8259s_cache) # set up same values in cache
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SYM(SetCS4):
|
SYM(SetCS4):
|
||||||
SetExRegWord(CS4ADL , 0x702) #Configure chip select 4
|
SetExRegWord(CS4ADL , 0x702) #Configure chip select 4
|
||||||
@@ -382,9 +386,40 @@ SYM(SetUCS):
|
|||||||
SetExRegWord(UCSMSKH, 0x0007)
|
SetExRegWord(UCSMSKH, 0x0007)
|
||||||
SetExRegWord(UCSMSKL, 0xFC01) # configure upper chip select
|
SetExRegWord(UCSMSKL, 0xFC01) # configure upper chip select
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SRAM chip select: 16 bit bus size,starting 16Mb, size 512k,
|
||||||
|
* 4 waits
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef UT_I386EX
|
||||||
|
|
||||||
|
SYM(SetCS1):
|
||||||
|
SetExRegWord(CS1ADL, 0x0000)
|
||||||
|
SetExRegWord(CS1ADH, 0x000E)
|
||||||
|
SetExRegWord(CS1MSKH, 0x0000)
|
||||||
|
SetExRegWord(CS1MSKL, 0x0001)
|
||||||
|
|
||||||
|
SYM(SetCS2):
|
||||||
|
SetExRegWord(CS2ADL, 0x0704)
|
||||||
|
SetExRegWord(CS2ADH, 0x0100)
|
||||||
|
SetExRegWord(CS2MSKH, 0x0003)
|
||||||
|
SetExRegWord(CS2MSKL, 0xfc01)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Real-time clock: 8 bit bus size, starting@16Mb+512K, size 32k
|
||||||
|
* 4 waits
|
||||||
|
*/
|
||||||
|
SYM(SetCS3):
|
||||||
|
SetExRegWord(CS3ADL, 0x0504)
|
||||||
|
SetExRegWord(CS3ADH, 0x0108)
|
||||||
|
SetExRegWord(CS3MSKH, 0x0000)
|
||||||
|
SetExRegWord(CS3MSKL, 0x7c01)
|
||||||
|
|
||||||
|
#endif
|
||||||
/***************************
|
/***************************
|
||||||
* Switch to Protected Mode
|
* Switch to Protected Mode
|
||||||
***************************/
|
***************************/
|
||||||
|
|
||||||
mov cr0, eax
|
mov cr0, eax
|
||||||
orw $0x1, ax
|
orw $0x1, ax
|
||||||
mov eax, cr0
|
mov eax, cr0
|
||||||
@@ -418,6 +453,7 @@ SYM (_establish_stack):
|
|||||||
movl $end, eax # stack starts right after bss
|
movl $end, eax # stack starts right after bss
|
||||||
movl $stack_origin, esp # this is the high starting address
|
movl $stack_origin, esp # this is the high starting address
|
||||||
movl $stack_origin, ebp
|
movl $stack_origin, ebp
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Zero out the BSS segment
|
* Zero out the BSS segment
|
||||||
*/
|
*/
|
||||||
@@ -432,12 +468,16 @@ SYM (zero_bss):
|
|||||||
repne # while ecx != 0
|
repne # while ecx != 0
|
||||||
stosl # clear a long in the bss
|
stosl # clear a long in the bss
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Transfer control to User's Board Support Package
|
* Transfer control to User's Board Support Package
|
||||||
*/
|
*/
|
||||||
pushl $0 # environp
|
pushl $0 # environp
|
||||||
pushl $0 # argv
|
pushl $0 # argv
|
||||||
pushl $0 # argc
|
pushl $0 # argc
|
||||||
|
|
||||||
|
movw $0xFFFB, SYM(i8259s_cache) # ICU mask values reflect
|
||||||
|
# initial ICU state
|
||||||
call SYM(boot_card)
|
call SYM(boot_card)
|
||||||
addl $12,esp
|
addl $12,esp
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user