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

Subversion Repositories rtf65002

[/] [rtf65002/] [trunk/] [software/] [asm/] [DeviceDriver.asm] - Blame information for rev 40

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 40 robfinch
 
2
; ============================================================================
3
;        __
4
;   \\__/ o\    (C) 2014  Robert Finch, Stratford
5
;    \  __ /    All rights reserved.
6
;     \/_//     robfinch@opencores.org
7
;       ||
8
;
9
;
10
; This source file is free software: you can redistribute it and/or modify
11
; it under the terms of the GNU Lesser General Public License as published
12
; by the Free Software Foundation, either version 3 of the License, or
13
; (at your option) any later version.
14
;
15
; This source file is distributed in the hope that it will be useful,
16
; but WITHOUT ANY WARRANTY; without even the implied warranty of
17
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
; GNU General Public License for more details.
19
;
20
; You should have received a copy of the GNU General Public License
21
; along with this program.  If not, see .
22
;
23
; ============================================================================
24
;
25
;------------------------------------------------------------------
26
; Initialize/install a device driver.
27
;
28
; Parameters:
29
;       r1 = device number
30
;       r2 = pointer to (static) DCB array
31
;       r3 = # of devices in array
32
;------------------------------------------------------------------
33
;
34
        cpu             RTF65002
35
InitDevDrv:
36
        push    r5
37
        push    r6
38
        push    r7
39
        cmp             #NR_DCB                                 ; check for a good device number
40
        bhs             .idd1
41
        mul             r5,r1,#DCB_SIZE
42
        add             r5,r5,#DCBs
43
        ld              r0,DCB_pDevOp,r5                ; check a pointer to see if device is setup
44
        beq             .idd2
45
        cmp             r4,#1
46
        beq             .idd2
47
        lda             #E_DCBInUse
48
        pop             r7
49
        pop             r6
50
        pop             r5
51
        rts
52
.idd2:
53
.idd4:
54
        ; Copy the DCB parameter to DCB array
55
        pha
56
        phy
57
        lda             #DCB_SIZE-1
58
        ld              r3,r5
59
        mvn
60
        ply
61
        pla
62
        ; Initialize device semaphores
63
        pha
64
        asl             r1,r1,#4                ; * 16 words per semaphore
65
        add             r1,r1,#device_semas
66
        sta             DCB_Sema,r5
67
        ld              r7,DCB_ReentCount,x     ; prime the semaphore
68
        st              r7,(r1)
69
        pla
70
        add             r5,r5,#DCB_SIZE
71
        add             r2,r2,#DCB_SIZE
72
        dey
73
        bne             .idd4
74
        pop             r7
75
        pop             r6
76
        pop             r5
77
        lda             #E_Ok
78
        rts
79
.idd1:
80
        pop             r7
81
        pop             r6
82
        pop             r5
83
        lda             #E_BadDevNum
84
        rts
85
 
86
;------------------------------------------------------------------
87
; Parameters:
88
;       r1 = device number
89
;------------------------------------------------------------------
90
;
91
public DeviceInit:
92
        cmp             #NR_DCB
93
        bhs             .dvi1
94
        phx
95
        push    r6
96
        mul             r2,r1,#DCB_SIZE
97
        add             r2,r2,#DCBs
98
        ld              r2,DCB_pDevInit,x       ; check a pointer to see if device is setup
99
        beq             .dvi2
100
 
101
        asl             r6,r1,#4
102
        spl             device_semas+1,r6       ; Wait for semaphore
103
        jsr             (x)
104
        stz             device_semas+1,r6       ; unlock device semaphore
105
        pop             r6
106
        plx
107
        ; lda # result from jsr() above
108
        rts
109
.dvi2:
110
        pop             r6
111
        plx
112
.dvi1:
113
        lda             #E_BadDevNum
114
        rts
115
 
116
;------------------------------------------------------------------
117
; Parameters:
118
;       r1 = device number
119
;       r2 = operation code
120
;       r3 = block address
121
;       r4 = number of blocks
122
;       r5 = pointer to data
123
;------------------------------------------------------------------
124
;
125
public DeviceOp:
126
        cmp             #NR_DCB
127
        bhs             dvo1
128
        push    r6
129
        push    r7
130
        mul             r6,r1,#DCB_SIZE
131
        add             r6,r6,#DCBs
132
        ld              r6,DCB_pDevOp,r6                ; check a pointer to see if device is setup
133
        beq             dvo2
134
 
135
        asl             r7,r1,#4
136
        spl             device_semas+1,r7               ; Wait for semaphore
137
        jsr             (r6)
138
        stz             device_semas+1,r7               ; unlock device semaphore
139
        pop             r7
140
        pop             r6
141
        rts
142
dvo2:
143
        pop             r7
144
        pop             r6
145
dvo1:
146
        lda             #E_BadDevNum
147
        rts
148
 
149
;------------------------------------------------------------------
150
; Parameters:
151
;       r1 = device number
152
;       r2 = pointer to status return buffer
153
;       r3 = size of buffer
154
;       r4 = pointer to status word returned
155
;------------------------------------------------------------------
156
;
157
public DeviceStat:
158
        cmp             #NR_DCB
159
        bhs             dvs1
160
        push    r6
161
        push    r7
162
        mul             r6,r1,#DCB_SIZE
163
        add             r6,r6,#DCBs
164
        ld              r6,DCB_pDevStat,r6              ; check a pointer to see if device is setup
165
        beq             dvs2
166
 
167
        asl             r7,r1,#4
168
        spl             device_semas+1,r7               ; Wait for semaphore
169
        jsr             (r6)                                    ; Call the stat function
170
        stz             device_semas+1,r7               ; unlock device semaphore
171
        pop             r7
172
        pop             r6
173
        rts
174
dvs2:
175
        pop             r7
176
        pop             r6
177
dvs1:
178
        lda             #E_BadDevNum
179
        rts
180
 
181
;------------------------------------------------------------------
182
; Load up the system's built in device drivers.
183
;------------------------------------------------------------------
184
 
185
public InitDevices:
186
        lda             #0
187
        ldx             #NullDCB>>2
188
        ldy             #1
189
        jsr             InitDevDrv
190
        lda             #1
191
        ldx             #KeybdDCB>>2
192
        ldy             #1
193
        jsr             InitDevDrv
194
        lda             #16
195
        ldx             #SDCardDCB>>2
196
        ldy             #1
197
        jsr             InitDevDrv
198
        rts
199
 
200
 
201
 

powered by: WebSVN 2.1.0

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