OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [tags/] [eco32-0.25/] [simtest/] [rom/] [romboot.s] - Diff between revs 9 and 248

Only display areas with differences | Details | Blame | View Log

Rev 9 Rev 248
;
;
; romboot.s -- the ROM bootstrap
; romboot.s -- the ROM bootstrap
;
;
 
 
        .set    termbase,0xF0300000     ; terminal base address
        .set    termbase,0xF0300000     ; terminal base address
        .set    diskbase,0xF0400000     ; disk base address
        .set    diskbase,0xF0400000     ; disk base address
        .set    diskbuffer,0xF0480000   ; disk buffer address
        .set    diskbuffer,0xF0480000   ; disk buffer address
        .set    virtbase,0xC0000000     ; base of kernel virtual addresses
        .set    virtbase,0xC0000000     ; base of kernel virtual addresses
        .set    virtboot,0xC0000000     ; where to start the bootstrap sector
        .set    virtboot,0xC0000000     ; where to start the bootstrap sector
        .set    stacktop,0xC0100000     ; where the stack is located
        .set    stacktop,0xC0100000     ; where the stack is located
 
 
        .set    PSW,0
        .set    PSW,0
        .set    TLB_INDEX,1
        .set    TLB_INDEX,1
        .set    TLB_ENTRY_HI,2
        .set    TLB_ENTRY_HI,2
        .set    TLB_ENTRY_LO,3
        .set    TLB_ENTRY_LO,3
        .set    TLB_ENTRIES,32
        .set    TLB_ENTRIES,32
 
 
        .code
        .code
 
 
reset:
reset:
        j       start
        j       start
 
 
interrupt:
interrupt:
        j       interrupt
        j       interrupt
 
 
miss:
miss:
        j       miss
        j       miss
 
 
start:
start:
        mvts    $0,PSW                   ; disable interrupts and user mode
        mvts    $0,PSW                   ; disable interrupts and user mode
        mvts    $0,TLB_ENTRY_LO          ; invalidate all TLB entries
        mvts    $0,TLB_ENTRY_LO          ; invalidate all TLB entries
        add     $8,$0,virtbase           ; by impossible virtual page number
        add     $8,$0,virtbase           ; by impossible virtual page number
        add     $9,$0,$0
        add     $9,$0,$0
        add     $10,$0,TLB_ENTRIES
        add     $10,$0,TLB_ENTRIES
tlblp:
tlblp:
        mvts    $8,TLB_ENTRY_HI
        mvts    $8,TLB_ENTRY_HI
        mvts    $9,TLB_INDEX
        mvts    $9,TLB_INDEX
        tbwi
        tbwi
        add     $8,$8,0x1000            ; all entries must be different
        add     $8,$8,0x1000            ; all entries must be different
        add     $9,$9,1
        add     $9,$9,1
        bne     $9,$10,tlblp
        bne     $9,$10,tlblp
        add     $29,$0,stacktop          ; set stack pointer
        add     $29,$0,stacktop          ; set stack pointer
        add     $4,$0,signon             ; show sign-on message
        add     $4,$0,signon             ; show sign-on message
        jal     mout
        jal     mout
cmdlp:
cmdlp:
        add     $4,$0,prompt             ; show prompt
        add     $4,$0,prompt             ; show prompt
        jal     mout
        jal     mout
        jal     echo
        jal     echo
        sub     $8,$2,0x0D              ; '<ret>'?
        sub     $8,$2,0x0D              ; '<ret>'?
        beq     $8,$0,rcmdlp
        beq     $8,$0,rcmdlp
        sub     $8,$2,'b'               ; 'b'?
        sub     $8,$2,'b'               ; 'b'?
        beq     $8,$0,boot
        beq     $8,$0,boot
        add     $4,$0,'?'                ; unknown command
        add     $4,$0,'?'                ; unknown command
        jal     cout
        jal     cout
rcmdlp:
rcmdlp:
        jal     crlf
        jal     crlf
        j       cmdlp
        j       cmdlp
 
 
boot:
boot:
        jal     crlf
        jal     crlf
        add     $8,$0,diskbase           ; check if disk present
        add     $8,$0,diskbase           ; check if disk present
        add     $9,$0,1000000            ; retry count
        add     $9,$0,1000000            ; retry count
boot1:
boot1:
        ldw     $16,$8,0         ; get status
        ldw     $16,$8,0         ; get status
        and     $10,$16,0x20            ; check if disk ready
        and     $10,$16,0x20            ; check if disk ready
        bne     $10,$0,boot2             ; ready - exit loop
        bne     $10,$0,boot2             ; ready - exit loop
        sub     $9,$9,1
        sub     $9,$9,1
        bne     $9,$0,boot1              ; try again
        bne     $9,$0,boot1              ; try again
        j       nodsk                   ; enough retries - error
        j       nodsk                   ; enough retries - error
boot2:
boot2:
        ldw     $16,$8,12               ; check if capacity greater than 0
        ldw     $16,$8,12               ; check if capacity greater than 0
        beq     $16,$0,nodsk             ; no - report error
        beq     $16,$0,nodsk             ; no - report error
        add     $4,$0,dfmsg              ; say that we found a disk
        add     $4,$0,dfmsg              ; say that we found a disk
        jal     mout
        jal     mout
        add     $4,$16,$0                ; and how many sectors it has
        add     $4,$16,$0                ; and how many sectors it has
        jal     wout
        jal     wout
        add     $4,$0,sctmsg
        add     $4,$0,sctmsg
        jal     mout
        jal     mout
        add     $8,$0,diskbase           ; try to load the boot sector
        add     $8,$0,diskbase           ; try to load the boot sector
        add     $9,$0,1                  ; sector count
        add     $9,$0,1                  ; sector count
        stw     $9,$8,4
        stw     $9,$8,4
        add     $9,$0,0                   ; first sector
        add     $9,$0,0                   ; first sector
        stw     $9,$8,8
        stw     $9,$8,8
        add     $9,$0,1                  ; start command
        add     $9,$0,1                  ; start command
        stw     $9,$8,0
        stw     $9,$8,0
dskwt:
dskwt:
        ldw     $9,$8,0
        ldw     $9,$8,0
        and     $9,$9,0x10              ; done?
        and     $9,$9,0x10              ; done?
        beq     $9,$0,dskwt
        beq     $9,$0,dskwt
        ldw     $9,$8,0
        ldw     $9,$8,0
        and     $9,$9,0x08              ; error?
        and     $9,$9,0x08              ; error?
        bne     $9,$0,dskerr
        bne     $9,$0,dskerr
        add     $8,$0,diskbuffer ; copy sector
        add     $8,$0,diskbuffer ; copy sector
        add     $9,$0,virtboot
        add     $9,$0,virtboot
        add     $10,$0,512
        add     $10,$0,512
dskcp:
dskcp:
        ldw     $11,$8,0
        ldw     $11,$8,0
        stw     $11,$9,0
        stw     $11,$9,0
        add     $8,$8,4
        add     $8,$8,4
        add     $9,$9,4
        add     $9,$9,4
        sub     $10,$10,4
        sub     $10,$10,4
        bne     $10,$0,dskcp
        bne     $10,$0,dskcp
        add     $8,$0,virtboot           ; signature present?
        add     $8,$0,virtboot           ; signature present?
        ldbu    $9,$8,512-2
        ldbu    $9,$8,512-2
        sub     $9,$9,0x55
        sub     $9,$9,0x55
        bne     $9,$0,nosig
        bne     $9,$0,nosig
        ldbu    $9,$8,512-1
        ldbu    $9,$8,512-1
        sub     $9,$9,0xAA
        sub     $9,$9,0xAA
        bne     $9,$0,nosig
        bne     $9,$0,nosig
        jalr    $8                      ; finally... lift off
        jalr    $8                      ; finally... lift off
        j       cmdlp                   ; in case we ever return to here
        j       cmdlp                   ; in case we ever return to here
 
 
nodsk:
nodsk:
        add     $4,$0,dnfmsg             ; there is no disk
        add     $4,$0,dnfmsg             ; there is no disk
        jal     mout
        jal     mout
        j       cmdlp
        j       cmdlp
 
 
dskerr:
dskerr:
        add     $4,$0,demsg              ; disk error
        add     $4,$0,demsg              ; disk error
        jal     mout
        jal     mout
        j       cmdlp
        j       cmdlp
 
 
nosig:
nosig:
        add     $4,$0,nsgmsg             ; no signature
        add     $4,$0,nsgmsg             ; no signature
        jal     mout
        jal     mout
        j       cmdlp
        j       cmdlp
 
 
crlf:
crlf:
        sub     $29,$29,4
        sub     $29,$29,4
        stw     $31,$29,0
        stw     $31,$29,0
        add     $4,$0,0x0D
        add     $4,$0,0x0D
        jal     cout
        jal     cout
        add     $4,$0,0x0A
        add     $4,$0,0x0A
        jal     cout
        jal     cout
        ldw     $31,$29,0
        ldw     $31,$29,0
        add     $29,$29,4
        add     $29,$29,4
        jr      $31
        jr      $31
 
 
mout:
mout:
        sub     $29,$29,8
        sub     $29,$29,8
        stw     $31,$29,4
        stw     $31,$29,4
        stw     $16,$29,0
        stw     $16,$29,0
        add     $16,$4,$0
        add     $16,$4,$0
mout1:
mout1:
        ldbu    $4,$16,0
        ldbu    $4,$16,0
        beq     $4,$0,mout2
        beq     $4,$0,mout2
        jal     cout
        jal     cout
        add     $16,$16,1
        add     $16,$16,1
        j       mout1
        j       mout1
mout2:
mout2:
        ldw     $16,$29,0
        ldw     $16,$29,0
        ldw     $31,$29,4
        ldw     $31,$29,4
        add     $29,$29,8
        add     $29,$29,8
        jr      $31
        jr      $31
 
 
wout:
wout:
        sub     $29,$29,8
        sub     $29,$29,8
        stw     $31,$29,4
        stw     $31,$29,4
        stw     $16,$29,0
        stw     $16,$29,0
        add     $16,$4,$0
        add     $16,$4,$0
        slr     $4,$16,16
        slr     $4,$16,16
        jal     hout
        jal     hout
        add     $4,$16,$0
        add     $4,$16,$0
        jal     hout
        jal     hout
        ldw     $16,$29,0
        ldw     $16,$29,0
        ldw     $31,$29,4
        ldw     $31,$29,4
        add     $29,$29,8
        add     $29,$29,8
        jr      $31
        jr      $31
 
 
hout:
hout:
        sub     $29,$29,8
        sub     $29,$29,8
        stw     $31,$29,4
        stw     $31,$29,4
        stw     $16,$29,0
        stw     $16,$29,0
        add     $16,$4,$0
        add     $16,$4,$0
        slr     $4,$16,8
        slr     $4,$16,8
        jal     bout
        jal     bout
        add     $4,$16,$0
        add     $4,$16,$0
        jal     bout
        jal     bout
        ldw     $16,$29,0
        ldw     $16,$29,0
        ldw     $31,$29,4
        ldw     $31,$29,4
        add     $29,$29,8
        add     $29,$29,8
        jr      $31
        jr      $31
 
 
bout:
bout:
        sub     $29,$29,8
        sub     $29,$29,8
        stw     $31,$29,4
        stw     $31,$29,4
        stw     $16,$29,0
        stw     $16,$29,0
        add     $16,$4,$0
        add     $16,$4,$0
        slr     $4,$16,4
        slr     $4,$16,4
        jal     nout
        jal     nout
        add     $4,$16,$0
        add     $4,$16,$0
        jal     nout
        jal     nout
        ldw     $16,$29,0
        ldw     $16,$29,0
        ldw     $31,$29,4
        ldw     $31,$29,4
        add     $29,$29,8
        add     $29,$29,8
        jr      $31
        jr      $31
 
 
nout:
nout:
        sub     $29,$29,4
        sub     $29,$29,4
        stw     $31,$29,0
        stw     $31,$29,0
        and     $4,$4,0x0F
        and     $4,$4,0x0F
        add     $4,$4,0x30
        add     $4,$4,0x30
        sub     $8,$4,0x3A
        sub     $8,$4,0x3A
        blt     $8,$0,nout1
        blt     $8,$0,nout1
        add     $4,$4,7
        add     $4,$4,7
nout1:
nout1:
        jal     cout
        jal     cout
        ldw     $31,$29,0
        ldw     $31,$29,0
        add     $29,$29,4
        add     $29,$29,4
        jr      $31
        jr      $31
 
 
cin:
cin:
        add     $8,$0,termbase
        add     $8,$0,termbase
cin1:
cin1:
        ldw     $9,$8,0
        ldw     $9,$8,0
        and     $9,$9,1
        and     $9,$9,1
        beq     $9,$0,cin1
        beq     $9,$0,cin1
        ldw     $2,$8,4
        ldw     $2,$8,4
        jr      $31
        jr      $31
 
 
cout:
cout:
        add     $8,$0,termbase
        add     $8,$0,termbase
cout1:
cout1:
        ldw     $9,$8,8
        ldw     $9,$8,8
        and     $9,$9,1
        and     $9,$9,1
        beq     $9,$0,cout1
        beq     $9,$0,cout1
        stw     $4,$8,12
        stw     $4,$8,12
        jr      $31
        jr      $31
 
 
echo:
echo:
        sub     $29,$29,4
        sub     $29,$29,4
        stw     $31,$29,0
        stw     $31,$29,0
        jal     cin
        jal     cin
        add     $4,$0,$2
        add     $4,$0,$2
        jal     cout
        jal     cout
        ldw     $31,$29,0
        ldw     $31,$29,0
        add     $29,$29,4
        add     $29,$29,4
        jr      $31
        jr      $31
 
 
signon:
signon:
        .byte   0x0D, 0x0A
        .byte   0x0D, 0x0A
        .byte   "ROM Bootstrap Version 1"
        .byte   "ROM Bootstrap Version 1"
        .byte   0x0D, 0x0A, 0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0x0D, 0x0A, 0
 
 
prompt:
prompt:
        .byte   "#"
        .byte   "#"
        .byte   0
        .byte   0
 
 
dnfmsg:
dnfmsg:
        .byte   "Disk not found!"
        .byte   "Disk not found!"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
dfmsg:
dfmsg:
        .byte   "Disk with 0x"
        .byte   "Disk with 0x"
        .byte   0
        .byte   0
 
 
sctmsg:
sctmsg:
        .byte   " sectors found, booting..."
        .byte   " sectors found, booting..."
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
demsg:
demsg:
        .byte   "Disk error!"
        .byte   "Disk error!"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 
nsgmsg:
nsgmsg:
        .byte   "MBR signature missing!"
        .byte   "MBR signature missing!"
        .byte   0x0D, 0x0A, 0
        .byte   0x0D, 0x0A, 0
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.