; Virtual Ports for the BIOS Interaction ; ; Copyright (C) 2010 Frank Zoll ; ; This file is part of avrcpm. ; ; avrcpm is free software: you can redistribute it and/or modify it ; under the terms of the GNU General Public License as published by ; the Free Software Foundation, either version 3 of the License, or ; (at your option) any later version. ; ; avrcpm 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 avrcpm. If not, see . ; ; $Id$ ; ; ---------------- Defines for the Virtual peripherial interface ------- ;The hw is modelled to make writing a CPM BIOS easier. ;Ports: ;0 - Con status. Returns 0xFF if the UART has a byte, 0 otherwise. ;1 - Console input, aka UDR. ;2 - Console output ;3 - "UART" status: bit 0=rx, bit 1 = tx ;4 - "UART" data register, no wait ;15 - Disk select ;16,17 - Track select ;18 - Sector select ;20 - Write addr l ;21 - Write addr h ;22 - Trigger - write to read, to write a sector using the above info; ; , write to allocated/dirctory/unallocated .equ READ_FUNC = 7 .equ WRITE_FUNC = 6 .equ BOOT_FUNC = 5 .equ HOME_FUNC = 4 ;----------------------------------------------- Start of Data Segment .dseg ; ---------------------------------------------- Start of Code Segment .cseg uartstat: clr temp lds temp2,rxcount cpse temp2,_0 sbr temp,0x01 lds temp2,txcount cpi temp2,TXBUFSIZE breq uartst_1 sbr temp,0x02 uartst_1: ret uartout: lds temp2,txcount cpi temp2,TXBUFSIZE breq uartout_1 rjmp uartputc uartout_1: ret uartin: clr temp lds temp2,rxcount cpse temp2,_0 rjmp uartgetc ret conStatus: lds temp,rxcount cpse temp,_0 ldi temp,0xff ret conInp: rjmp uartgetc dbgOut: printnewline printstring "Debug: " rcall printhex ret conOut: rjmp uartputc ;Called with port in temp2. Should return value in temp. portRead: cpi temp2,0 breq conStatus cpi temp2,1 breq conInp cpi temp2,3 breq uartstat cpi temp2,4 breq uartin cpi temp2,15 breq dskDiskCheck cpi temp2,22 breq dskErrorRet cpi temp2,TIMER_MSECS brlo pr_noclock cpi temp2,TIMER_MSECS+6 brsh pr_noclock rjmp clockget pr_noclock: ldi temp,0xFF ret ;Called with port in temp2 and value in temp. portWrite: cpi temp2,0 breq dbgOut cpi temp2,2 breq conOut cpi temp2,4 breq uartout cpi temp2,15 breq dskDiskSel cpi temp2,16 breq dskTrackSel_l cpi temp2,17 breq dskTrackSel_h cpi temp2,18 breq dskSecSel cpi temp2,20 breq dskDmaL cpi temp2,21 breq dskDmaH cpi temp2,22 breq dskDoIt cpi temp2,TIMERPORT brlo pw_noclock cpi temp2,TIMER_MSECS+6 brsh pw_noclock rjmp clockput pw_noclock: ret ;---------------------------------------------------------------------