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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [monitor/] [monitor/] [common/] [dskctl.s] - Blame information for rev 299

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

Line No. Rev Author Line
1 59 hellwig
;
2 182 hellwig
; dskctl.s -- disk made available by disk controller
3 59 hellwig
;
4
 
5
;***************************************************************
6
 
7
        .set    dskbase,0xF0400000      ; disk base address
8
        .set    dskctrl,0                ; control register
9
        .set    dskcnt,4                ; count register
10
        .set    dsksct,8                ; sector register
11
        .set    dskcap,12               ; capacity register
12
        .set    dskbuf,0x00080000       ; disk buffer
13
 
14
        .set    ctrlstrt,0x01           ; start bit
15
        .set    ctrlien,0x02            ; interrupt enable bit
16
        .set    ctrlwrt,0x04            ; write bit
17
        .set    ctrlerr,0x08            ; error bit
18
        .set    ctrldone,0x10           ; done bit
19
        .set    ctrlrdy,0x20            ; ready bit
20
 
21
        .set    sctsize,512             ; sector size in bytes
22
 
23
        .set    retries,1000000         ; retries to get disk ready
24
 
25 184 hellwig
        .export dskinitctl              ; initialize disk
26 182 hellwig
        .export dskcapctl               ; determine disk capacity
27
        .export dskioctl                ; do disk I/O
28 59 hellwig
 
29
;***************************************************************
30
 
31
        .code
32
        .align  4
33
 
34 184 hellwig
dskinitctl:
35 182 hellwig
        jr      $31
36
 
37
dskcapctl:
38 59 hellwig
        add     $8,$0,retries            ; set retry count
39
        add     $9,$0,dskbase
40 182 hellwig
dskcap1:
41 59 hellwig
        ldw     $10,$9,dskctrl
42
        and     $10,$10,ctrlrdy         ; ready?
43 182 hellwig
        bne     $10,$0,dskcapok          ; yes - jump
44 59 hellwig
        sub     $8,$8,1
45 182 hellwig
        bne     $8,$0,dskcap1            ; try again
46 59 hellwig
        add     $2,$0,0                   ; no disk found
47 182 hellwig
        j       dskcapx
48
dskcapok:
49 59 hellwig
        ldw     $2,$9,dskcap            ; get disk capacity
50 182 hellwig
dskcapx:
51 59 hellwig
        jr      $31
52
 
53 182 hellwig
dskioctl:
54 59 hellwig
        sub     $29,$29,24
55
        stw     $31,$29,20
56
        stw     $16,$29,16
57
        stw     $17,$29,12
58
        stw     $18,$29,8
59
        stw     $19,$29,4
60
        stw     $20,$29,0
61
        add     $16,$4,$0                ; command
62
        add     $17,$5,$0                ; sector number
63
        add     $18,$6,0xC0000000       ; memory address, virtualized
64
        add     $19,$7,$0                ; number of sectors
65
 
66
        add     $8,$0,'r'
67 182 hellwig
        beq     $16,$8,dskrd
68 59 hellwig
        add     $8,$0,'w'
69 182 hellwig
        beq     $16,$8,dskwr
70 59 hellwig
        add     $2,$0,0xFF               ; illegal command
71 182 hellwig
        j       dskx
72 59 hellwig
 
73 182 hellwig
dskrd:
74 59 hellwig
        add     $2,$0,$0          ; return ok
75 182 hellwig
        beq     $19,$0,dskx              ; if no (more) sectors
76 59 hellwig
        add     $8,$0,dskbase
77
        add     $9,$0,1
78
        stw     $9,$8,dskcnt            ; number of sectors
79
        stw     $17,$8,dsksct           ; sector number on disk
80
        add     $9,$0,ctrlstrt
81
        stw     $9,$8,dskctrl           ; start command
82 182 hellwig
dskrd1:
83 59 hellwig
        ldw     $2,$8,dskctrl
84
        and     $9,$2,ctrldone          ; done?
85 182 hellwig
        beq     $9,$0,dskrd1             ; no - wait
86 59 hellwig
        and     $9,$2,ctrlerr           ; error?
87 182 hellwig
        bne     $9,$0,dskx               ; yes - leave
88 59 hellwig
        add     $8,$0,dskbase + dskbuf   ; transfer data
89
        add     $9,$0,sctsize
90 182 hellwig
dskrd2:
91 59 hellwig
        ldw     $10,$8,0         ; from disk buffer
92
        stw     $10,$18,0                ; to memory
93
        add     $8,$8,4
94
        add     $18,$18,4
95
        sub     $9,$9,4
96 182 hellwig
        bne     $9,$0,dskrd2
97 59 hellwig
        add     $17,$17,1               ; increment sector number
98
        sub     $19,$19,1               ; decrement number of sectors
99 182 hellwig
        j       dskrd                   ; next sector
100 59 hellwig
 
101 182 hellwig
dskwr:
102 59 hellwig
        add     $2,$0,$0          ; return ok
103 182 hellwig
        beq     $19,$0,dskx              ; if no (more) sectors
104 59 hellwig
        add     $8,$0,dskbase + dskbuf   ; transfer data
105
        add     $9,$0,sctsize
106 182 hellwig
dskwr1:
107 59 hellwig
        ldw     $10,$18,0                ; from memory
108
        stw     $10,$8,0         ; to disk buffer
109
        add     $18,$18,4
110
        add     $8,$8,4
111
        sub     $9,$9,4
112 182 hellwig
        bne     $9,$0,dskwr1
113 59 hellwig
        add     $8,$0,dskbase
114
        add     $9,$0,1
115
        stw     $9,$8,dskcnt            ; number of sectors
116
        stw     $17,$8,dsksct           ; sector number on disk
117
        add     $9,$0,ctrlwrt | ctrlstrt
118
        stw     $9,$8,dskctrl           ; start command
119 182 hellwig
dskwr2:
120 59 hellwig
        ldw     $2,$8,dskctrl
121
        and     $9,$2,ctrldone          ; done?
122 182 hellwig
        beq     $9,$0,dskwr2             ; no - wait
123 59 hellwig
        and     $9,$2,ctrlerr           ; error?
124 182 hellwig
        bne     $9,$0,dskx               ; yes - leave
125 59 hellwig
        add     $17,$17,1               ; increment sector number
126
        sub     $19,$19,1               ; decrement number of sectors
127 182 hellwig
        j       dskwr                   ; next sector
128 59 hellwig
 
129 182 hellwig
dskx:
130 59 hellwig
        ldw     $20,$29,0
131
        ldw     $19,$29,4
132
        ldw     $18,$29,8
133
        ldw     $17,$29,12
134
        ldw     $16,$29,16
135
        ldw     $31,$29,20
136
        add     $29,$29,24
137
        jr      $31

powered by: WebSVN 2.1.0

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