source: rtems/c/src/lib/libbsp/i386/pc386/startup/ldsegs.s @ 5d18fb0

4.104.114.84.95
Last change on this file since 5d18fb0 was 5d18fb0, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 27, 1998 at 6:51:49 PM

PC386 BSP enhancements from Aleksey Romanov (Quality Quorum
<qqi@…>). Unfortunately after merging these,
the pc386 will not boot using grub for for. It still does not
work using netboot for me. Here is his summary of changes:

rtems/c/src/lib/libbsp/i386/pc386/Makefile.in

Added support for new sub-directory

rtems/c/src/lib/libbsp/i386/pc386/bsp_specs

Made possible to build COFF image

rtems/c/src/lib/libbsp/i386/pc386/console/console.c

Added support for serial consoles, selectable by patching
binary image, added assert(), use _IBMPC_inch_sleep()
instaed of _IMBPC_inch()

rtems/c/src/lib/libbsp/i386/pc386/console/inch.c

Added _IMBPC_inch_sleep()

rtems/c/src/lib/libbsp/i386/pc386/console/outch.c

Oops - just formatting

rtems/c/src/lib/libbsp/i386/pc386/include/Makefile.in

Added support for new files

rtems/c/src/lib/libbsp/i386/pc386/include/bsp.h

Added support for new features

rtems/c/src/lib/libbsp/i386/pc386/include/pc386uart.h

New file: definitions for serial ports

rtems/c/src/lib/libbsp/i386/pc386/include/pcibios.h

New file: definitions for PCI BIOS

rtems/c/src/lib/libbsp/i386/pc386/pc386dev/Makefile.in

New file: makefile in new directory

rtems/c/src/lib/libbsp/i386/pc386/pc386dev/i386-stub-glue.c

New file: i386-stub interface

rtems/c/src/lib/libbsp/i386/pc386/pc386dev/i386-stub.c

New file: i386-stub itself

rtems/c/src/lib/libbsp/i386/pc386/pc386dev/pc386uart.c

New file: serial ports

rtems/c/src/lib/libbsp/i386/pc386/pc386dev/pcibios.c

New file: PCI BIOS support

rtems/c/src/lib/libbsp/i386/pc386/start/start.s

Commented out DEBUG_EARLY stuff, everything is working fine

rtems/c/src/lib/libbsp/i386/pc386/start/start16.s

Cleaned up

rtems/c/src/lib/libbsp/i386/pc386/startup/bspstart.c

Added call to console_resereve_resources

rtems/c/src/lib/libbsp/i386/pc386/startup/exit.c

Added support for serial console

rtems/c/src/lib/libbsp/i386/pc386/startup/ldsegs.s

Fixed typo in comments

rtems/c/src/lib/libbsp/i386/pc386/tools/Makefile.in

Changed to reflect cnages in code

rtems/c/src/lib/libbsp/i386/pc386/tools/bin2boot.c

Trivialized, problem - I do not know how to make patch
remove obsolete files - there are a lot of them there

rtems/c/src/lib/libbsp/i386/pc386/tools/binpatch.c

New file: utility to do binary patches

rtems/c/src/lib/libbsp/i386/pc386/wrapup/Makefile.in

Added support for new directory

rtems/make/custom/pc386.cfg

Add COFF image building

  • Property mode set to 100644
File size: 7.5 KB
Line 
1/*-------------------------------------------------------------------------+
2| ldsegs.s v1.1 - PC386 BSP - 1997/08/07
3+--------------------------------------------------------------------------+
4| This file assists the board independent startup code by loading the proper
5| segment register values. The values loaded are board dependent. In addition
6| it contains code to enable the A20 line and to reprogram the PIC to relocate
7| the IRQ interrupt vectors to 0x20 -> 0x2f.
8| NOTE: No stack has been established when this routine is invoked.
9|       It returns by jumping back to bspentry.
10+--------------------------------------------------------------------------+
11| (C) Copyright 1997 -
12| - NavIST Group - Real-Time Distributed Systems and Industrial Automation
13|
14| http://pandora.ist.utl.pt
15|
16| Instituto Superior Tecnico * Lisboa * PORTUGAL
17+--------------------------------------------------------------------------+
18| Disclaimer:
19|
20| This file is provided "AS IS" without warranty of any kind, either
21| expressed or implied.
22+--------------------------------------------------------------------------+
23| This code is base on:
24|   ldsegs.s,v 1.4 1996/04/20 16:48:30 joel Exp - go32 BSP
25| With the following copyright notice:
26| **************************************************************************
27| *  COPYRIGHT (c) 1989-1998.
28| *  On-Line Applications Research Corporation (OAR).
29| *  Copyright assigned to U.S. Government, 1994. 
30| *
31| *  The license and distribution terms for this file may be
32| *  found in found in the file LICENSE in this distribution or at
33| *  http://www.OARcorp.com/rtems/license.html.
34| **************************************************************************
35|
36|  $Id$
37|
38| Also based on (from the Linux source tree):
39|   setup.S - Copyright (C) 1991, 1992 Linus Torvalds
40+--------------------------------------------------------------------------*/
41
42
43#include "asm.h"
44
45/*----------------------------------------------------------------------------+
46| CODE section
47+----------------------------------------------------------------------------*/
48
49BEGIN_CODE
50
51        EXTERN (_establish_stack)
52        EXTERN (Timer_exit)
53        EXTERN (Clock_exit)
54
55        .p2align 4
56/*----------------------------------------------------------------------------+
57| delay
58+------------------------------------------------------------------------------
59| Delay is needed after doing I/O. We do it by writing to a non-existent port.
60+----------------------------------------------------------------------------*/
61SYM(delay):
62        outb    al, $0xED       # about 1uS delay
63        ret
64
65/*-------------------------------------------------------------------------+
66|         Function: _load_segments
67|      Description: Current environment is standard PC booted by grub.
68|                   So, there is no value in saving current GDT and IDT
69|                   settings we have to set it up ourseves. (Naturally
70|                   it will be not so in case we are booted by some
71|                   boot monitor, however, then it will be different
72|                   BSP). After that we have to load board segment registers
73|                   with apropriate values +  reprogram PIC.
74| Global Variables: None.
75|        Arguments: None.
76|          Returns: Nothing.
77+--------------------------------------------------------------------------*/
78        .p2align 4
79       
80        PUBLIC (_load_segments)
81SYM (_load_segments):
82
83        lgdt SYM(gdtdesc)
84        lidt SYM(idtdesc)
85
86        /* Load CS, flush prefetched queue */
87        ljmp $0x8, $next_step
88
89next_step:     
90        /* Load segment registers */
91        movw $0x10, ax
92        movw ax, ss
93        movw ax, ds
94        movw ax, es
95        movw ax, fs
96        movw ax, gs
97
98        /* Set default interrupt handler */
99        movl  $0, ecx
100        movl  $Interrupt_descriptor_table, eax
101        movl  $_default_int_handler, ebx
102        movl  ebx, edx
103        sarl  $16, edx
104loop:
105        movw  bx, (eax)
106        movw  $0x8, 2(eax)
107        movw  $0x8e00, 4(eax)
108        movw  dx, 8(eax)
109        addl  $8, eax
110        addl  $1, ecx
111        cmpl  $255, ecx
112        jle   loop
113       
114       
115       
116
117/*---------------------------------------------------------------------+
118| Now we have to reprogram the interrupts :-(. We put them right after
119| the intel-reserved hardware interrupts, at int 0x20-0x2F. There they
120| won't mess up anything. Sadly IBM really messed this up with the
121| original PC, and they haven't been able to rectify it afterwards. Thus
122| the bios puts interrupts at 0x08-0x0f, which is used for the internal
123| hardware interrupts as well. We just have to reprogram the 8259's, and
124| it isn't fun.
125+---------------------------------------------------------------------*/
126
127        movb    $0x11, al               /* initialization sequence          */
128        outb    al, $0x20               /* send it to 8259A-1               */
129        call    SYM(delay)
130        outb    al, $0xA0               /* and to 8259A-2                   */
131        call    SYM(delay)
132       
133        movb    $0x20, al               /* start of hardware int's (0x20)   */
134        outb    al, $0x21
135        call    SYM(delay)
136        movb    $0x28, al               /* start of hardware int's 2 (0x28) */
137        outb    al, $0xA1
138        call    SYM(delay)
139       
140        movb    $0x04, al               /* 8259-1 is master                 */
141        outb    al, $0x21
142        call    SYM(delay)
143        movb    $0x02, al               /* 8259-2 is slave                  */
144        outb    al, $0xA1
145        call    SYM(delay)
146       
147        movb    $0x01, al               /* 8086 mode for both               */
148        outb    al, $0x21
149        call    SYM(delay)
150        outb    al, $0xA1
151        call    SYM(delay)
152       
153        movb    $0xFF, al               /* mask off all interrupts for now  */
154        outb    al, $0xA1
155        call    SYM(delay)
156        movb    $0xFB, al               /* mask all irq's but irq2 which    */
157        outb    al, $0x21               /* is cascaded                      */
158        call    SYM(delay)
159
160        jmp     SYM (_establish_stack)  # return to the bsp entry code
161
162/*-------------------------------------------------------------------------+
163|         Function: _return_to_monitor
164|      Description: Return to board's monitor (we have none so simply restart).
165| Global Variables: None.
166|        Arguments: None.
167|          Returns: Nothing.
168+--------------------------------------------------------------------------*/
169
170        .p2align 4
171       
172        PUBLIC (_return_to_monitor)
173SYM (_return_to_monitor):
174
175        call    SYM (Timer_exit)
176        call    SYM (Clock_exit)
177        jmp     SYM (start)
178
179/*-------------------------------------------------------------------------+
180|         Function: _default_int_handler
181|      Description: default interrupt handler
182| Global Variables: None.
183|        Arguments: None.
184|          Returns: Nothing.
185+--------------------------------------------------------------------------*/
186        .p2align 4
187       
188        PUBLIC (_default_int_handler)
189SYM (_default_int_handler):
190        iret
191
192/*---------------------------------------------------------------------------+
193| GDT itself
194+--------------------------------------------------------------------------*/
195
196        .p2align 4
197               
198        PUBLIC (_Global_descriptor_table)
199SYM (_Global_descriptor_table):
200
201        /* NULL segment */
202        .word 0, 0     
203        .byte 0, 0, 0, 0
204
205        /* code segment */
206        .word 0xffff, 0
207        .byte 0, 0x9e, 0xcf, 0
208
209        /* data segment */
210        .word 0xffff, 0
211        .byte 0, 0x92, 0xcf, 0
212 
213
214/*---------------------------------------------------------------------------+
215| Descriptor of GDT
216+--------------------------------------------------------------------------*/
217SYM (gdtdesc):
218        .word (3*8 - 1) 
219        .long SYM (_Global_descriptor_table)
220
221
222/*---------------------------------------------------------------------------+
223| IDT itself
224+---------------------------------------------------------------------------*/
225        .p2align 4
226       
227        PUBLIC(Interrupt_descriptor_table)
228SYM(Interrupt_descriptor_table):
229        .rept 256
230        .word 0,0,0,0
231        .endr
232       
233/*---------------------------------------------------------------------------+
234| Descriptor of IDT
235+--------------------------------------------------------------------------*/
236SYM(idtdesc):   
237        .word  (256*8 - 1)
238        .long  SYM (Interrupt_descriptor_table)
239       
240END_CODE
241
242END
Note: See TracBrowser for help on using the repository browser.