NEW AUTO 3,1 */-------------------------------------- * # GetDevByName * Y,A = Ptr to device name (C-String) * ## RETURN VALUE * CC = OK, CS = ERROR * Y,A = FD * X = hFD *\-------------------------------------- K.GetDevByName >STYA ZPPtr1 requested dev name ldx #1 .1 lda hFDs-1,x beq .7 sta IO.hFD jsr K.GetMemPtr >STYA pFD lda hFDs.hName-1,x bne .2 jsr DEV.GetPDrv lda pFD clc adc #S.FD.DEV sta ZPPtr2 lda pFD+1 adc /S.FD.DEV sta ZPPtr2+1 bra .3 .2 jsr K.GetMemPtr >STYA ZPPtr2 lda (ZPPtr2) cmp #'/' REG/DIR beq .7 .3 ldy #$ff .4 iny lda (ZPPtr1),y cmp (ZPPtr2),y bne .7 eor #0 bne .4 stx IO.hFILE >LDYA pFD ldx IO.hFD clc rts .7 inx no....loop cpx #K.hFD.MAX+1 bne .1 lda #MLI.E.NODEV * sec K.GetDev.9 rts */-------------------------------------- * # MkFD * ## C * `short int mkfd(short int type, );` * ## ASM * `>PUSHB DevID` * `>PUSHW S.DIB` * `>SYSCALL MkFD` * ## RETURN VALUE *\-------------------------------------- K.MkFD clc rts */-------------------------------------- * # MKDev * Create a hDEV * ## C * `hDEV mkdev (S.FD *fd, const char *devname)` * ## ASM * `>PUSHW fd` * `>PUSHW devname` * `>SYSCALL mkdev` * ## RETURN VALUE * A = hDEV *\-------------------------------------- K.MKDev jsr SHARED.PullP2P1 ptr2=name,ptr1=fd ldy #$ff ldx #S.FD.DEV .1 iny Get DEV name length inx compute FD+NAME+\0 in X lda (ZPPtr2),y bne .1 txa tay lda #S.FD.T.CDEV jsr DEV.MkFDy bcs .9 >STYA .4+1 ldy #S.FD.DEV-1 .2 lda (ZPPtr1),y sta (pFD),y dey bpl .2 ldy #$ff ldx #S.FD.DEV-1 .3 iny inx lda (ZPPtr2),y .4 sta $ffff,x bne .3 >LDYAI K.IOBuf >STYA K.S.IOCTL+S.IOCTL.BUFPTR ldy #S.FD.DEV.DRVPTR+1 lda (pFD),y bne .5 lda /DRV.SmartPort sta (pFD),y dey lda #DRV.SmartPort sta (pFD),y .5 jsr DEV.GetPDrv lda #S.IOCTL.S.STATUS jsr DEV.GetStatus bcs .9 lda K.IOBuf Get Status byte bit #S.DIB.S.IRQ beq .8 ldx #0 .6 lda IRQ.Vectors+1,x beq .7 inx inx cpx #K.IRQDEV.MAX*2+1 bne .6 * sec .9 rts .7 ldy #IOCTL.IRQ+4 lda (pDRV),y sta IRQ.Vectors,x iny lda (pDRV),y sta IRQ.Vectors+1,x .8 lda IO.hFD * clc rts */-------------------------------------- * # IOCTL * ## C * `int ioctl(short int hFD, short int request, void *param);` * ## ASM * `>PUSHB hDEV` * `>PUSHB request` * `>PUSHW param` * `>SYSCALL IOCTL` * ## RETURN VALUE * Y,A = ... *\-------------------------------------- K.IOCTL ldy #3 hFD lda (pStack),y jsr DEV.GetPFD ldy #2 request lda (pStack),y tax >PULLYA param inc pStack inc pStack jmp (pDrv) *-------------------------------------- DEV.OPEN ldx #IOCTL.OPEN * lda IO.hFD jsr DEV.pDrvJmp bcs .9 lda IO.hFD .9 rts *-------------------------------------- DEV.READ ldx #IOCTL.READ .HS 2C BIT ABS *-------------------------------------- DEV.WRITE ldx #IOCTL.WRITE >PULLW K.S.IOCTL+S.IOCTL.BYTECNT >PULLW K.S.IOCTL+S.IOCTL.BUFPTR inc pStack pop hFD jsr DEV.pDrvJmp bcs .9 >LDYA K.S.IOCTL+S.IOCTL.BYTECNT .9 rts *-------------------------------------- DEV.EOF lda #S.IOCTL.S.EOF *-------------------------------------- DEV.GetStatus sta K.S.IOCTL+S.IOCTL.S ldx #IOCTL.STATUS .HS 2C BIT ABS *-------------------------------------- DEV.CLOSE ldx #IOCTL.CLOSE *-------------------------------------- DEV.pDrvJmp >LDYAI K.S.IOCTL jmp (pDrv) *-------------------------------------- DEV.GetPFD sta IO.hFD jsr K.GetMemPtr >STYA pFD DEV.GetPDrv ldy #S.FD.DEV.DRVPTR lda (pFD),y sta pDRV iny lda (pFD),y sta pDRV+1 rts *-------------------------------------- DEV.MkFD ldy #16 Y = Size, MAX=16 for S.FD.DIR DEV.MkFDy sta .8+1 A = S.FD.T jsr DEV.GetFreeFD bcs .9 .2 stx IO.hFILE lda #0 ldx #S.MEM.F.INIT0+S.MEM.F.FD jsr MEM.GetMem.YAX bcs .9 >STYA pFD stx IO.hFD jsr Mem.SetOwnerPS0 txa .7 ldx IO.hFILE sta hFDs-1,x stz hFDs.hName-1,x .8 lda #$ff SELF MODIFIED sta (pFD) >LDYA pFD Y,A = pFD, X = hFILE * clc .9 rts *-------------------------------------- DEV.GetFreeFD lda #0 DEV.GetFD ldx #1 .1 cmp hFDs-1,x beq DEV.GetFD.8 inx cpx #K.hFD.MAX+1 bne .1 tax beq DEV.GetFD.8 lda #E.INVH .HS 2C BIT ABS .9 lda #E.OOH * sec rts DEV.GetFD.8 clc rts *-------------------------------------- DEV.hFDFree lda IO.hFD beq DEV.GetFD.8 jmp K.FreeMem *-------------------------------------- MAN SAVE usr/src/sys/kernel.s.dev LOAD usr/src/sys/kernel.s ASM