URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [lib/] [libbsp/] [i386/] [pc386/] [start/] [start.S] - Rev 1765
Compare with Previous | Blame | View Log
/*-------------------------------------------------------------------------+| start.s v1.1 - PC386 BSP - 1997/08/07+--------------------------------------------------------------------------+| This file contains the entry point for the application.| The name of this entry point is compiler dependent.| It jumps to the BSP which is responsible for performing all initialization.+--------------------------------------------------------------------------+| (C) Copyright 1997 -| - NavIST Group - Real-Time Distributed Systems and Industrial Automation|| http://pandora.ist.utl.pt|| Instituto Superior Tecnico * Lisboa * PORTUGAL+--------------------------------------------------------------------------+| Modified the 20/05/1998 by valette@crf.canon.fr in order to give a working| example of eraly stage debugging via the DEBUG_EARLY_START define.+--------------------------------------------------------------------------+| Disclaimer:|| This file is provided "AS IS" without warranty of any kind, either| expressed or implied.+--------------------------------------------------------------------------+| This code is based on an earlier generation RTEMS i386 start.s and the| following copyright applies:|| **************************************************************************| * COPYRIGHT (c) 1989-1999.| * On-Line Applications Research Corporation (OAR).| *| * The license and distribution terms for this file may be| * found in the file LICENSE in this distribution or at| * http://www.OARcorp.com/rtems/license.html.| **************************************************************************|| start.S,v 1.3 2000/12/05 16:49:22 joel Exp+--------------------------------------------------------------------------*//** The most trivial start.s possible. It does not know anything* about system it is running on, so it will jump to appropriate* place in BSP specific place to do things it knows nothing about*/#include "asm.h"/*----------------------------------------------------------------------------+| Size of heap and stack:+----------------------------------------------------------------------------*/.set STACK_SIZE, 0x1000/*----------------------------------------------------------------------------+| CODE section+----------------------------------------------------------------------------*/BEGIN_CODEPUBLIC (start) # GNU default entry pointEXTERN (boot_card)EXTERN (_load_segments)EXTERN (_return_to_monitor)EXTERN (_IBMPC_initVideo)EXTERN (debugPollingGetChar)EXTERN (checkCPUtypeSetCr0)/** In case this crashes on your machine and this is not due* to video mode set by the loader, you may try to define* the following variable:*//* #define DEBUG_EARLY_START */SYM (start):/** When things are really, REALLY!, bad -- turn on the speaker and* lock up. This shows whether or not we make it to a certain* location.*/#if 0inb $0x61, alorb $0x03, aloutb al, $0x61 # enable the speakerspeakl: jmp speakl # and SPIN!!!#endifnopcli # DISABLE INTERRUPTS!!!cld#ifdef DEBUG_EARLY_START/** Must get video attribute to have a working printk.* Note that the following code assume we already have* valid segments and a stack. It should be true for* any loader starting RTEMS in protected mode (or* at least I hope so : -)).*/call _IBMPC_initVideo/** try printk and a getchar in polling mode ASAP*/pushl $welcome_msgcall printkaddl $4, esp/* call debugPollingGetChar */#endif/*----------------------------------------------------------------------------+| Load the segment registers (this is done by the board's BSP) and perform any| other board specific initialization procedures, this piece of code| does not know anything about|| NOTE: Upon return, gs will contain the segment descriptor for a segment which| maps directly to all of physical memory.+----------------------------------------------------------------------------*/jmp SYM (_load_segments) # load board dependent segments/*----------------------------------------------------------------------------+| Set up the stack+----------------------------------------------------------------------------*/PUBLIC (_establish_stack)SYM (_establish_stack):movl $_end, eax # eax = end of bss/start of heapaddl $STACK_SIZE, eax # make room for stackandl $0xffffffc0, eax # align it on 16 byte boundarymovl eax, esp # set stack pointermovl eax, ebp # set base pointer/*----------------------------------------------------------------------------+| Zero out the BSS segment+----------------------------------------------------------------------------*/SYM (zero_bss):cld # make direction flag count upmovl $ SYM (_end), ecx # find end of .bssmovl $ SYM (_bss_start), edi # edi = beginning of .bsssubl edi, ecx # ecx = size of .bss in bytesshrl ecx # size of .bss in longsshrl ecxxorl eax, eax # value to clear out memoryrepne # while ecx != 0stosl# clear a long in the bss/*-------------------------------------------------------------------+| Initialize the video because zero_bss has cleared initVideo parameters| if it was called earlier| So from now we can use printk+-------------------------------------------------------------------*/call _IBMPC_initVideo/*---------------------------------------------------------------------+| Check CPU type. Enable Cache and init coprocessor if needed.+---------------------------------------------------------------------*/call checkCPUtypeSetCr0/*---------------------------------------------------------------------+| Transfer control to User's Board Support Package+---------------------------------------------------------------------*/pushl $0 # environppushl $0 # argvpushl $0 # argccall SYM (boot_card)addl $12, esp/*---------------------------------------------------------------------+| Clean up - we do not know anything about it, so we will| jump to BSP specific code to do cleanup+---------------------------------------------------------------------*/jmp SYM (_return_to_monitor)END_CODEBEGIN_DATAPUBLIC(_stack_size)SYM(_stack_size):.long STACK_SIZE#ifdef DEBUG_EARLY_STARTPUBLIC (welcome_msg)SYM (welcome_msg) :.string "Ready to debug RTEMS ?\nEnter <CR>\n"PUBLIC (hex_msg)SYM (hex_msg) :.string "0x%x\n"PUBLIC (made_it_msg)SYM (made_it_msg) :.string "made it to %d\n"#endifEND_DATAEND
