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

Subversion Repositories eco32

[/] [eco32/] [tags/] [eco32-0.24/] [disk/] [tools/] [fs-Linux/] [mkboot/] [br.s] - Blame information for rev 206

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 206 hellwig
;
2
; br.s -- the boot record
3
;
4
 
5
; Runtime environment:
6
;
7
; This code must be loaded and started at 0xC0010000.
8
; It allocates a stack from 0xC0011000 downwards. So
9
; it must run within 4K (code + data + stack).
10
;
11
; This code expects the disk number of the boot disk
12
; in $16, the start sector of the disk or partition
13
; to be booted in $17 and its size in $18.
14
;
15
; The Linux binary image (together with the tiny "mvstrt"
16
; program), which is loaded by this code, must be in
17
; standalone (headerless) executable format, stored at
18
; partition relative disk sectors 1..8192, and gets
19
; loaded and started at 0xC0400000.
20
 
21
        .set    stacktop,0xC0011000     ; top of stack
22
        .set    loadaddr,0xC0400000     ; where to load the image
23
 
24
        .set    cout,0xC0000020         ; the monitor's console output
25
        .set    dskio,0xC0000028        ; the monitor's disk I/O
26
 
27
        ; load the image and start it
28
start:
29
        add     $29,$0,stacktop          ; setup stack
30
        add     $4,$0,strtmsg            ; say what is going on
31
        jal     msgout
32
        ; $19 = sector number
33
        ; $20 = load address
34
        ; $21 = sectors left
35
        add     $19,$0,1         ; start loading with sector 1
36
        add     $20,$0,loadaddr          ; where to load the image
37
        add     $21,$0,8192              ; how many sectors to load
38
start1:
39
        add     $4,$0,'.'
40
        jal     chrout
41
        add     $4,$0,$19
42
        add     $5,$0,$20
43
        and     $5,$5,0x3FFFFFFF
44
        add     $6,$0,256                ; load in pieces of 256 sectors
45
        jal     rdsct
46
        add     $19,$19,256
47
        add     $20,$20,256*512
48
        sub     $21,$21,256
49
        bgt     $21,$0,start1
50
        add     $4,$0,mvmsg              ; say what is going on
51
        jal     msgout
52
        add     $8,$0,loadaddr           ; start executing mvstrt
53
        jr      $8
54
 
55
        ; read disk sectors
56
        ;   $4 start sector number (disk or partition relative)
57
        ;   $5 transfer address
58
        ;   $6 number of sectors
59
rdsct:
60
        sub     $29,$29,32
61
        stw     $31,$29,20
62
        stw     $6,$29,16               ; sector count
63
        add     $7,$5,$0         ; transfer address
64
        add     $6,$4,$17               ; relative sector -> absolute
65
        add     $5,$0,'r'                ; command
66
        add     $4,$0,$16                ; disk number
67
        add     $8,$0,dskio
68
        jalr    $8
69
        bne     $2,$0,rderr              ; error?
70
        ldw     $31,$29,20
71
        add     $29,$29,32
72
        jr      $31
73
 
74
        ; disk read error
75
rderr:
76
        add     $4,$0,dremsg
77
        jal     msgout
78
        j       halt
79
 
80
        ; output message
81
        ;   $4 pointer to string
82
msgout:
83
        sub     $29,$29,8
84
        stw     $31,$29,4
85
        stw     $16,$29,0
86
        add     $16,$4,0         ; $16: pointer to string
87
msgout1:
88
        ldbu    $4,$16,0         ; get character
89
        beq     $4,$0,msgout2            ; done?
90
        jal     chrout                  ; output character
91
        add     $16,$16,1               ; bump pointer
92
        j       msgout1                 ; continue
93
msgout2:
94
        ldw     $16,$29,0
95
        ldw     $31,$29,4
96
        add     $29,$29,8
97
        jr      $31
98
 
99
        ; output character
100
        ;   $4 character
101
chrout:
102
        sub     $29,$29,4
103
        stw     $31,$29,0
104
        add     $8,$0,cout
105
        jalr    $8
106
        ldw     $31,$29,0
107
        add     $29,$29,4
108
        jr      $31
109
 
110
        ; halt execution by looping
111
halt:
112
        add     $4,$0,hltmsg
113
        jal     msgout
114
halt1:
115
        j       halt1
116
 
117
        ; messages
118
strtmsg:
119
        .byte   "Loading image ", 0
120
mvmsg:
121
        .byte   0x0D, 0x0A, "Moving image", 0x0D, 0x0A, 0
122
dremsg:
123
        .byte   "Disk read error", 0x0D, 0x0A, 0
124
hltmsg:
125
        .byte   "Bootstrap halted", 0x0D, 0x0A, 0
126
 
127
        ; boot record signature
128
        .locate 512-2
129
        .byte   0x55, 0xAA

powered by: WebSVN 2.1.0

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