?? sysalib.s
字號:
/* sysALib.s - PC-386 system-dependent routines *//* Copyright 1984-2002 Wind River Systems, Inc. *//*modification history--------------------01z,13mar02,hdn resumed GDT loading after copying from text to RAM (spr 71298)01y,02nov01,hdn removed GDT loading not to access sysGdt[] in text (spr 71298)01x,14aug01,hdn added Pentium4 support in sysCpuProbe(). added sysCsSuper/Exc/Int as task/exc/int code selector. added FUNC/FUNC_LABEL GTEXT/GDATA macros.01w,12may98,hdn renamed sysCpuid to sysCpuId.01v,09apr98,hdn added support for PentiumPro in sysCpuProbe().01u,25mar97,hdn removed a line of CD=NW=1 from sysCpuProbe().01t,03sep96,hdn added the compression support. removed BOOTABLE macro.01s,17jun96,hdn made sysCpuProbe() user-callable.01r,13jun96,hdn added sysInLong() sysInLongString() sysOutLong() sysOutLongString().01q,01nov94,hdn added a way to find out Pentium in sysCpuProbe(). changed a way to find out 386 by checking AC bit.01p,19oct94,hdn renamed sysInitGdt to sysGdt. added sysLoadGdt(), sysA20on(). added sysA20Result indicates the state of A20 line.01o,23sep94,hdn deleted _sysBootType, sysRegSet(), sysRegGet(). added jmp instruction in sysInXX() and sysOutXX().01n,28apr94,hdn made sysReboot() simple.01m,06apr94,hdn created a processor checking routine sysCpuProbe(). created the system GDT at GDT_BASE_OFFSET.01l,17feb94,hdn changed name RAM_ENTRY to RAM_HIGH_ADRS changed to put the image in upper memory.01k,27oct93,hdn added _sysBootType.01j,25aug93,hdn changed a way to enable A20.01i,12aug93,hdn added codes to load a user defined global descriptor table. made warm start works changing sysReboot(). deleted sysGDTRSet().01h,09aug93,hdn added codes to recognize a type of cpu.01g,17jun93,hdn updated to 5.1.01f,08arp93,jdi doc cleanup.01e,26mar93,hdn added sysReg[GS]et, sysGDTRSet. added another sysInit.01d,16oct92,hdn added Code Descriptors for the nesting interrupt.01c,29sep92,hdn added i80387 support. deleted __fixdfsi.01b,28aug92,hdn fixed __fixdfsi temporary.01a,28feb92,hdn written based on frc386 version.*//*DESCRIPTIONThis module contains system-dependent routines written in assemblylanguage.This module must be the first specified in the \f3ld\f1 command used tobuild the system. The sysInit() routine is the system start-up code.INTERNALMany routines in this module doesn't use the "c" frame pointer %ebp@ !This is only for the benefit of the stacktrace facility to allow it to properly trace tasks executing within these routines.SEE ALSO: .I "i80386 32-Bit Microprocessor User's Manual"*/#define _ASMLANGUAGE#include "vxWorks.h"#include "asm.h"#include "regs.h"#include "sysLib.h"#include "config.h" .data .globl FUNC(copyright_wind_river) .long FUNC(copyright_wind_river) /* externals */ .globl FUNC(usrInit) /* system initialization routine */ .globl VAR(sysProcessor) /* initialized to NONE(-1) in sysLib.c */ /* internals */ .globl sysInit /* start of system code */ .globl _sysInit /* start of system code */ .globl GTEXT(sysInByte) .globl GTEXT(sysInWord) .globl GTEXT(sysInLong) .globl GTEXT(sysInWordString) .globl GTEXT(sysInLongString) .globl GTEXT(sysOutByte) .globl GTEXT(sysOutWord) .globl GTEXT(sysOutLong) .globl GTEXT(sysOutWordString) .globl GTEXT(sysOutLongString) .globl GTEXT(sysReboot) .globl GTEXT(sysWait) .globl GTEXT(sysCpuProbe) .globl GTEXT(sysLoadGdt) .globl GTEXT(sysGdtr) .globl GTEXT(sysGdt) .globl GDATA(sysCsSuper) /* code selector: supervisor mode */ .globl GDATA(sysCsExc) /* code selector: exception */ .globl GDATA(sysCsInt) /* code selector: interrupt */ .text .balign 16/********************************************************************************* sysInit - start after boot** This routine is the system start-up entry point for VxWorks in RAM, the* first code executed after booting. It disables interrupts, sets up* the stack, and jumps to the C routine usrInit() in usrConfig.c.** The initial stack is set to grow down from the address of sysInit(). This* stack is used only by usrInit() and is never used again. Memory for the* stack must be accounted for when determining the system load address.** NOTE: This routine should not be called by the user.** RETURNS: N/A* sysInit () /@ THIS IS NOT A CALLABLE ROUTINE @/ */sysInit:_sysInit: cli /* LOCK INTERRUPT */ movl $ BOOT_WARM_AUTOBOOT,%ebx /* %ebx has the startType */ movl $ FUNC(sysInit),%esp /* initialize stack pointer */ movl $0,%ebp /* initialize frame pointer */ ARCH_REGS_INIT /* initialize DR[0-7] CR[04] EFLAGS */ movl $ FUNC(sysGdt),%esi /* set src addr (&sysGdt) */ movl FUNC(pSysGdt),%edi /* set dst addr (pSysGdt) */ movl %edi,%eax movl $ GDT_ENTRIES,%ecx /* number of GDT entries */ movl %ecx,%edx shll $1,%ecx /* set (nLongs of GDT) to copy */ cld rep movsl /* copy GDT from src to dst */ pushl %eax /* push the (GDT base addr) */ shll $3,%edx /* get (nBytes of GDT) */ decl %edx /* get (nBytes of GDT) - 1 */ shll $16,%edx /* move it to the upper 16 */ pushl %edx /* push the nBytes of GDT - 1 */ leal 2(%esp),%eax /* get the addr of (size:addr) */ pushl %eax /* push it as a parameter */ call FUNC(sysLoadGdt) /* load the brand new GDT in RAM */ pushl %ebx /* push the startType */ movl $ FUNC(usrInit),%eax movl $ FUNC(sysInit),%edx /* push return address */ pushl %edx /* for emulation for call */ pushl $0 /* push EFLAGS, 0 */ pushl $0x0008 /* a selector 0x08 is 2nd one */ pushl %eax /* push EIP, FUNC(usrInit) */ iret /* iret *//********************************************************************************* sysInByte - input one byte from I/O space** RETURNS: Byte data from the I/O port.* UCHAR sysInByte (address)* int address; /@ I/O port address @/ */ .balign 16,0x90FUNC_LABEL(sysInByte) movl SP_ARG1(%esp),%edx movl $0,%eax inb %dx,%al jmp sysInByte0sysInByte0: ret/********************************************************************************* sysInWord - input one word from I/O space** RETURNS: Word data from the I/O port.* USHORT sysInWord (address)* int address; /@ I/O port address @/ */ .balign 16,0x90FUNC_LABEL(sysInWord) movl SP_ARG1(%esp),%edx movl $0,%eax inw %dx,%ax jmp sysInWord0sysInWord0: ret/********************************************************************************* sysInLong - input one long-word from I/O space** RETURNS: Long-Word data from the I/O port.* USHORT sysInLong (address)* int address; /@ I/O port address @/ */ .balign 16,0x90FUNC_LABEL(sysInLong) movl SP_ARG1(%esp),%edx movl $0,%eax inl %dx,%eax jmp sysInLong0sysInLong0: ret/********************************************************************************* sysOutByte - output one byte to I/O space** RETURNS: N/A* void sysOutByte (address, data)* int address; /@ I/O port address @/* char data; /@ data written to the port @/ */ .balign 16,0x90FUNC_LABEL(sysOutByte) movl SP_ARG1(%esp),%edx movl SP_ARG2(%esp),%eax outb %al,%dx jmp sysOutByte0sysOutByte0: ret/********************************************************************************* sysOutWord - output one word to I/O space** RETURNS: N/A* void sysOutWord (address, data)* int address; /@ I/O port address @/* short data; /@ data written to the port @/ */ .balign 16,0x90FUNC_LABEL(sysOutWord) movl SP_ARG1(%esp),%edx movl SP_ARG2(%esp),%eax outw %ax,%dx jmp sysOutWord0sysOutWord0: ret/********************************************************************************* sysOutLong - output one long-word to I/O space** RETURNS: N/A* void sysOutLong (address, data)* int address; /@ I/O port address @/* long data; /@ data written to the port @/ */ .balign 16,0x90FUNC_LABEL(sysOutLong) movl SP_ARG1(%esp),%edx movl SP_ARG2(%esp),%eax outl %eax,%dx jmp sysOutLong0sysOutLong0: ret/********************************************************************************* sysInWordString - input word string from I/O space** RETURNS: N/A* void sysInWordString (port, address, count)* int port; /@ I/O port address @/* short *address; /@ address of data read from the port @/* int count; /@ count @/ */ .balign 16,0x90FUNC_LABEL(sysInWordString) pushl %edi movl SP_ARG1+4(%esp),%edx movl SP_ARG2+4(%esp),%edi movl SP_ARG3+4(%esp),%ecx cld rep insw %dx,(%edi) movl %edi,%eax popl %edi ret/********************************************************************************* sysInLongString - input long string from I/O space** RETURNS: N/A* void sysInLongString (port, address, count)* int port; /@ I/O port address @/* long *address; /@ address of data read from the port @/* int count; /@ count @/ */ .balign 16,0x90FUNC_LABEL(sysInLongString) pushl %edi movl SP_ARG1+4(%esp),%edx movl SP_ARG2+4(%esp),%edi movl SP_ARG3+4(%esp),%ecx cld rep insl %dx,(%edi) movl %edi,%eax popl %edi ret/********************************************************************************* sysOutWordString - output word string to I/O space** RETURNS: N/A* void sysOutWordString (port, address, count)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -