URL
https://opencores.org/ocsvn/rtf65002/rtf65002/trunk
Subversion Repositories rtf65002
[/] [rtf65002/] [trunk/] [software/] [asm/] [DeviceDriver.asm] - Rev 40
Compare with Previous | Blame | View Log
; ============================================================================; __; \\__/ o\ (C) 2014 Robert Finch, Stratford; \ __ / All rights reserved.; \/_// robfinch<remove>@opencores.org; ||;;; This source file is free software: you can redistribute it and/or modify; it under the terms of the GNU Lesser General Public License as published; by the Free Software Foundation, either version 3 of the License, or; (at your option) any later version.;; This source file is distributed in the hope that it will be useful,; but WITHOUT ANY WARRANTY; without even the implied warranty of; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the; GNU General Public License for more details.;; You should have received a copy of the GNU General Public License; along with this program. If not, see <http://www.gnu.org/licenses/>.;; ============================================================================;;------------------------------------------------------------------; Initialize/install a device driver.;; Parameters:; r1 = device number; r2 = pointer to (static) DCB array; r3 = # of devices in array;------------------------------------------------------------------;cpu RTF65002InitDevDrv:push r5push r6push r7cmp #NR_DCB ; check for a good device numberbhs .idd1mul r5,r1,#DCB_SIZEadd r5,r5,#DCBsld r0,DCB_pDevOp,r5 ; check a pointer to see if device is setupbeq .idd2cmp r4,#1beq .idd2lda #E_DCBInUsepop r7pop r6pop r5rts.idd2:.idd4:; Copy the DCB parameter to DCB arrayphaphylda #DCB_SIZE-1ld r3,r5mvnplypla; Initialize device semaphoresphaasl r1,r1,#4 ; * 16 words per semaphoreadd r1,r1,#device_semassta DCB_Sema,r5ld r7,DCB_ReentCount,x ; prime the semaphorest r7,(r1)plaadd r5,r5,#DCB_SIZEadd r2,r2,#DCB_SIZEdeybne .idd4pop r7pop r6pop r5lda #E_Okrts.idd1:pop r7pop r6pop r5lda #E_BadDevNumrts;------------------------------------------------------------------; Parameters:; r1 = device number;------------------------------------------------------------------;public DeviceInit:cmp #NR_DCBbhs .dvi1phxpush r6mul r2,r1,#DCB_SIZEadd r2,r2,#DCBsld r2,DCB_pDevInit,x ; check a pointer to see if device is setupbeq .dvi2asl r6,r1,#4spl device_semas+1,r6 ; Wait for semaphorejsr (x)stz device_semas+1,r6 ; unlock device semaphorepop r6plx; lda # result from jsr() aboverts.dvi2:pop r6plx.dvi1:lda #E_BadDevNumrts;------------------------------------------------------------------; Parameters:; r1 = device number; r2 = operation code; r3 = block address; r4 = number of blocks; r5 = pointer to data;------------------------------------------------------------------;public DeviceOp:cmp #NR_DCBbhs dvo1push r6push r7mul r6,r1,#DCB_SIZEadd r6,r6,#DCBsld r6,DCB_pDevOp,r6 ; check a pointer to see if device is setupbeq dvo2asl r7,r1,#4spl device_semas+1,r7 ; Wait for semaphorejsr (r6)stz device_semas+1,r7 ; unlock device semaphorepop r7pop r6rtsdvo2:pop r7pop r6dvo1:lda #E_BadDevNumrts;------------------------------------------------------------------; Parameters:; r1 = device number; r2 = pointer to status return buffer; r3 = size of buffer; r4 = pointer to status word returned;------------------------------------------------------------------;public DeviceStat:cmp #NR_DCBbhs dvs1push r6push r7mul r6,r1,#DCB_SIZEadd r6,r6,#DCBsld r6,DCB_pDevStat,r6 ; check a pointer to see if device is setupbeq dvs2asl r7,r1,#4spl device_semas+1,r7 ; Wait for semaphorejsr (r6) ; Call the stat functionstz device_semas+1,r7 ; unlock device semaphorepop r7pop r6rtsdvs2:pop r7pop r6dvs1:lda #E_BadDevNumrts;------------------------------------------------------------------; Load up the system's built in device drivers.;------------------------------------------------------------------public InitDevices:lda #0ldx #NullDCB>>2ldy #1jsr InitDevDrvlda #1ldx #KeybdDCB>>2ldy #1jsr InitDevDrvlda #16ldx #SDCardDCB>>2ldy #1jsr InitDevDrvrts
