News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

changing bootstrap address..

Started by som, March 26, 2007, 12:39:37 PM

Previous topic - Next topic

som

Hi,

Am working on a project which Requires testing SRAM before system (intel486) boots up.This can be done by booting from a PCMCIA card and checking for SRAM (data and address line tests).The system architecture is such that the system boots up from PCMCIA card only if the bootstrap address is at a specified address in PCMCIA card. As i should not use Stack i have opted for purely assemby language program to perform testing . As of now am working on displaying test results either by RS232 interface or LED port and later the complete test .attached is the code snippet of what i have written for this .Code has been written as per UART data sheet to intialize . Now the problem i am facing is assembler is assinging the boot strap (reset_exec) addrress as starting address of SRAM @ 0H and it has to be changed to the specified address of PCMCIA card.I have also attached the linker options i have used , linker options i have used is not changing bootstrap adress :( help me with your suggestions.. as am new to assembly programming ..


.386P   
DGROUP segment DWORD public use32 'data'
DSP_CODE_DES     equ        18h  ; GDT(3) Code - All Memory
DSP_DATA_DES     equ   20h  ; GDT(4) Data - All Memory
INITIAL_STACK     equ     1FFFEFh ;
DGROUP ends
opprefx MACRO
        db 66H
ENDM
extrn ram_start: near
cseg16  segment DWORD public use32 'code'
assume  cs:cseg16
assume ds: DGROUP

        public reset_exec
        public  pGDT
        public  pIDT

; We begin executing in real mode and transfer to protected mode as soon
; as the minimal tables are set.

reset_exec:
   
    CLI                             ; disable interrupts
    CLD                               ; clear direction flag
;
; Load Descriptor Table Registers:
;
    opprefx                         ; Force 32 bit Operand
    LGDT fword ptr pGDT             ; load global descriptor registers
    opprefx                         ; Force 32 bit Operand
    LIDT fword ptr pIDT             ; load interrupt descriptor registers

;
; Switch to protected mode:
;
    MOV   EAX,CR0
    OR    EAX,1                     ; set PE bit
    MOV   CR0,EAX
;
; Jump to clear prefetch queue:
;
    JMP   flush             

flush:
;
;   Initialize data selectors
;

    MOV   BX,DSP_DATA_DES
    MOV   DS,BX
    MOV   SS,BX
    MOV   ES,BX
    MOV   GS,BX
    MOV   FS,BX
;
;   Set up the stack at the top of the first block of RAM
;
    MOV   ESP,INITIAL_STACK



    JMP ram_start         ; Jump to the C_Start up Code

    pGDT    dw 00EFh      ; GDT Limit
            dd 0FC3FFFFFh  ; GDT Physical Address
    pIDT    dw 01FFh       ; IDT Limit
            dd 0FFFFFD00h  ; IDT Physical Address
cseg16  ends
End   

; next file

.386P   ; Use 386 commands

       

code32  segment dword public use32 'code'

   assume  cs:code32

        public  ram_start

; Now perform intersegment jump to refresh the CS register.

ram_start:

        db  66H                         ;opprefx
        jmp far ptr   start_code

start_code:

mov   eax,00B00000h  ; initialize control port settings for power up
mov     ebx,0000h
mov     [eax] ,ebx
       
; initialize LRU UART
mov    eax,00500001h  ; disable the receiver ready interrupt
mov     ebx,0h
mov     [eax] ,ebx
mov    eax ,00500004h ; enabling the data terminal ready to indicate UART is ready to receive data
mov     ebx,0h
mov     [eax],ebx

mov eax,00500003h ; select diviser latch register
mov     ebx,80h
mov     [eax],ebx

mov eax,00500001h
mov     ebx,0h
mov     [eax],ebx
mov eax,00500000h ; writing into transmit hold reg to transmitt the data in the data bus
mov     ebx,1Ah
mov     [eax],ebx
   
mov eax,00500003h   ;specifying word length to be 8
mov     ebx,3h
mov     [eax],ebx

mov eax,0050000h   ;clearing Rx buffer register
mov     ebx,[eax]
mov eax,0050002h   ;clearing interrupt ID  register
mov     ebx,[eax]
mov eax,0050006h   ;clearing modem status register
mov     ebx,[eax]

        mov     eax ,00500000h
        mov     ebx , 41h
        mov     [eax], ebx

        mov     eax ,00A00000h
        mov     ebx , 02h
        mov     [eax], ebx
      
       
        hlt

code32   ENDS

   end
   //linker options

    splink  resvec.obj, ramtestp.obj -Output(pbc) -debug -flat -pubmap -NOWARNINGS(260) -bootstrap(reset_exec)  -BUILDFILE(pbc; SEGMENT DGROUP(DPL=3, BASE=0H, LIMIT=6FFFFH, RW, ROMINIT),CSEG16(BASE=0FC3FFFFFH, OFFSET=00000H, USEREAL),CODE32(BASE=0FFD00000H, OFFSET=00000H);TASK TSS0 (BASE=0FC40FAFFH, DPL=0, LIMIT=0);TABLE LDT0 (BASE=0FC40FBFFH, DPL=0, LIMIT=8);TABLE GDT (BASE=0FC40FDFFH, LIMIT=10, DPL=0, PRESENT, CREATED,ENTRY=(6:TSS0, 7:LDT0));ORDER SEGMENTS( DGROUP, CODE32,CSEG16);SEGSYM SEGMENTS(*SEGMENTS);END)
                 

Mark_Larson

  If this is you are just learning assembly language, then you should really start with an easier project.  This is a lot to bite off if you aren't  better at assembly language.

BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

u

Can't a simple "org" assembler-command before "reset_exec" help? Is the expected address in the PCMCIA card known, and a fixed value? Is it 0FC3FFFFFH?
Please use a smaller graphic in your signature.

mnemonic

I think the hint with ORG is the right way.
And IIRC, the resulting file must not be an Windows or DOS EXE but rather a "plain binary" file (like a COM prog, e.g.). I read some stuff about that in the past, but most people seem to use the GNU-tools for that purpose .
Remember, that in that early stage of booting, without an OS, you have to do everything "by hand". Your code usually just gets loaded from disk to memory and then being CALLed oder JMPed to.

Have a look here: http://www.osdev.org/osfaq2/
That is the usual site I dig up when I want to know about some pre-OS stuff.
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

som

hi,

Thank you  :U am able to change the address by including linker option in make file