Subversion Repositories MB01 Project

Rev

Blame | Last modification | View Log | Download | RSS feed

;;
;; Copyright (c) 2016 Marco Granati <mg@unet.bz>
;;
;; Permission to use, copy, modify, and distribute this software for any
;; purpose with or without fee is hereby granted, provided that the above
;; copyright notice and this permission notice appear in all copies.
;;
;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
;;

;; name: tossys.inc     
;; rev.: 2016/02/09
;; o.s. 65C816 version v1.0

.LIST on

;---------------------------------------------------------------------------

HPLMAX          .EQU    32              ; Max. subdirectory level

BCBCNT          .EQU    $200            ; BCB's struct's count #
BCBXBNK         .EQU    $0C00           ; starting BCB x-mem buffer #
DMACNT          .EQU    64

FAT0X           .EQU    $E0             ; x-mem bank for fat table of ata #0
FAT1X           .EQU    $F0             ; x-mem bank for fat table of ata #1

        .INCLUDE INC\LDT.INC
        
;---------------------------------------------------------------------------
; Hierarchical Path List (HPL) -- 16 bit offset's
;---------------------------------------------------------------------------

 LSTRUCT        HPL
hpl_cls         .DW             ; parent cluster
hpl_ix          .DW             ; entry index in parent cluster
hpl_fcb         .DS     11      ; fcb name
hpl_lst         .DB             ; unused
 ESTRUCT        HPL

;--------------------------------------------------------------------------- 
; Buffer Control Block (BCB) -- 16 bit offset's
;---------------------------------------------------------------------------

 LSTRUCT        BCB
bcb_next        .DW                     ; next logical linked BCB 
bcb_drv         .DB                     ; logical drive
bcb_sec         .DB                     ; sector offset
bcb_cls         .DW                     ; cluster
bcb_lba         .DW                     ; sector lba address
bcb_lbah        .DW                     ; lba high
bcb_head        .EQU    bcb_lbah        ; floppy head
bcb_buf         .DW                     ; x-mem buffer number
bcb_trk         .EQU    bcb_buf         ; floppy track(low) & sector(hi)
bcb_ptr         .DW                     ; buffer pointer
bcb_xbnk        .DW                     ; buffer pointer hi & x-mem bank
bcb_dma         .EQU    bcb_xbnk        ; buffer pointer hi & dma buffer
 ESTRUCT        BCB

;--------------------------------------------------------------------------- 
; hash Control Block (BCB) -- 16 bit offset's
;---------------------------------------------------------------------------

 LSTRUCT        HCB
hcb_next        .DW             ; pointer to next HCB
hcb_cls         .DW             ; cluster number
hcb_seq         .DW             ; sequence number + logical drive number
hcb_cnt         .DW             ; number of hashed entries
hcb_data        .DS     0        ; hash buffer data
 ESTRUCT        HCB

;---------------------------------------------------------------------------  
; TOS Working Segment
;--------------------------------------------------------------------------- 

WKB             .EQU    .SEG.TOSSEG     ; TOS working bank

TS              .SET    TOSSEG
TE              .SET    TOSSEG + $FFFF
TO0             .SET    $018C00
TO1             .SET    TOSWKM

.comment @
_TOS0:  .SECTION ref_only, common, offset TO0, range TS TE ;FAT Struct's
_TOS0_START     .DS     0

_pbr0           .DS     512
_pbr1           .DS     512
_pbr2           .DS     512
_pbr3           .DS     512

_TOS0_END       .DS     0
TOS0SIZ         .EQU    (_TOS0_END - _TOS0_START)
.ENDS
@

_TOS1:  .SECTION ref_only, common, offset TO1, range TS TE ;FAT Struct's
_TOS1_START     .DS     0

; current working directory HPL  
cwdl0           .DS     (HPLSIZE*HPLMAX)
cwdl1           .DS     (HPLSIZE*HPLMAX)
cwdl2           .DS     (HPLSIZE*HPLMAX)
cwdl3           .DS     (HPLSIZE*HPLMAX)

; current building path HPL
cbpl            .DS     (HPLSIZE*HPLMAX)
HPL_CLS         .EQU    hpl_cls+cbpl
HPL_IX          .EQU    hpl_ix+cbpl
HPL_FCB         .EQU    hpl_fcb+cbpl

; BCB list's
bcbstart        .DS     (BCBCNT*BCBSIZE)
bcbend          .DS     0
dmastart        .DS     (DMACNT*BCBSIZE)
dmaend          .DS     0
dma0s           .DS     (17*BCBSIZE)
dma1s           .DS     (17*BCBSIZE)

_TOS1_END       .DS     0
TOS1SIZ         .EQU    (_TOS1_END - _TOS1_START)
.ENDS

;---------------------------------------------------------------------------  
; HCB Segment
;--------------------------------------------------------------------------- 

HCBBNK          .EQU    .SEG.HCBSEG
HS              .SET    HCBSEG
HE              .SET    HCBSEG + $FFFF
HO              .SET    HCBSEG

_HCBS:  .SECTION ref_only, common, offset HO, range HS HE       ;HCB's List
hcb_bnk         .DS     8
hcbstart        .DS     0
.ENDS

;.comment @
;---------------------------------------------------------------------------
; direct page for LDT var's 
;---------------------------------------------------------------------------

; P0OS
DPOS:   .SECTION page0, common, ref_only, offset 0      ;OS Main D.P.

;sysbuf         .DS     2       ; floppy track 0 cache buffer
defhsec         .DB             ; default hidden sector's in fdisk
                .DB
cmdstk          .DW             ; saved stack on TOS command's
bpath           .DS     80

bpath1          .DS     0
.ENDS
;@

; P0LDT
DPLDT:  .SECTION page0, common, ref_only, offset 0      ;LDT D.P.

ldt0            .DS     LDTSIZE
ldt1            .DS     LDTSIZE
ldt2            .DS     LDTSIZE
ldt3            .DS     LDTSIZE
ldt4            .DS     LDTSIZE

ldtp            .DS     6       ; pointer to LDT's in DPLDT page

sysbuf          .DS     4       ; floppy track 0 cache buffer

.ENDS

;---------------------------------------------------------------------------
; direct page for FAT var's 
;---------------------------------------------------------------------------

; P0FAT
DPFAT:  .SECTION page0, common, ref_only, offset 0      ;FAT D.P.

ostos           .DW             ; saved top of stack
ioerr           .DB             ; i/o error
ioerr2          .DB             ; extended i/o error
hcbroot         .DW             ; HCB struct's list
hcblst          .DW             ; the last one HCB
hsiz            .DB             ; how many sector's an HCB can hold
hlog2           .DB             ; shift count related to hsiz
bcbroot         .DW             ; BCB buffer's list
bcblst          .DW             ; the last one BCB
dmaroot         .DW             ; dma BCB buffer's list
dmalst          .DW             ; the last one dma BCB
dmabcb          .DW             ; BCB list for floppy root, cluster#2,#3&#4
fspt            .DB             ; sector per track (floppy)
pdrive          .DB             ; phisycal drive number
bplvl           .DB             ; subdir level while build path
defdrv          .DB             ; default drive

; the first block of ldt_ var's is copied from the LDT struct
ldtfg1          .DB             ; logical volume flag's
                                ; <7>: device ready (fdc drive or ata device)
                                ; <6>: if=1->HD/CF else->FD
                                ; <0>: phisycal device number

ldtfg2          .DB             ; <7>: valid volume (fat volume or cbm disk)
                                ; <6>: if=1->FAT else->CBM (FD only)
                                ; <5>: disk format checked
                                ; <1:0>: disk format (fdc only)

ldtfp           LP              ; fat table buffer long pointer
ldtfbuf         .DB             ; fat table: x-mem base bank/dma buffer

ldtroot         .DW             ; lba of root dir
ldtfat1         .DW             ; lba of fat1 table
ldtfat2         .DW             ; lba of fat2 table
ldtcls          .DW             ; lba of first data cluster
ldtmax          .DW             ; max usable cluster + 1
ldtcsiz         .DB             ; cluster size (1,2,4,8,16,32,64)
ldtcshf         .DB             ; cluster shift (0,1,2,3,4,5,6)
ldtfsiz         .DB             ; fat table size (if 0 -> 256)
ldtrsiz         .DB             ; root dir. size (sector's)
ldtrent         .DW             ; root dir. max. entries
ldtcent         .DW             ; max. entries in dir. cluster
ldteoc          .DW             ; end of cluster chain marker
ldtmcls         .DB             ; mask for clust. module: 00,01,03,07,0F,1F,3F
ldtfmt          .DB             ; floppy disk format (0,1,2, FF if ata device)
ldtcdlp         .DW             ; current working dir list pointer
ldtcdcls        .DW             ; current working dir start cluster
ldtfree         .DW             ; count of free cluster's
ldtnxt          .DW             ; next free cluster
ldtcdlvl        .DB             ; current working dir level count
ldtpbr          LP              ; long pointer to PBR cache buffer

chdcls          .DW             ; last accessed chained dir. cluster
clsofs          .DW             ; cluster's offset from start of chain

; not change order of the 2 following var's: will be accessed as 16 bit var
entofs          .DB             ; entry offset from start of sector
secofs          .DB             ; sector's offset from start of cluster

dircls          .DW             ; directory cluster 
dcnt            .DW             ; directory entry counter 
lba             .DW             ; lba sector address
lbah            .DW             ; lba is 24 bit's only
xbuf            .DW             ; x-mem buffer transfer number

fhead           .EQU    lbah    ; fd head
ftrack          .EQU    xbuf    ; fd track
fsec            .EQU    xbuf+1  ; fd sector

dfcbtyp         .DB             ; FCB type to search 
dfcbatt         .DB             ; attribute of found FCB

curdrv          .DB             ; current logical drive
fcbs            .DS     11      ; file control block name

;dcmask         .DW             ; mask to start of cluster
                                ; FFF0, FFE0, FFC0, FF80, FF00, FE00

fcbp            .DW             ; FCB buffer long pointer
                .DW             ; low=fcbp+2, high=x-mem bank or dma buffer
dmabuf          .EQU    fcbp+3  ; dma buffer #
xmbank          .EQU    fcbp+3  ; x-mem bank #

; temp area
hcbseq          .DB
hcbdrv          .DB
bcbcls          .DW
bcbdrv          .DB
bcbsec          .DB

thash           .DW
hcbrec  .EQU    thash
wtmp    .EQU    thash

hlast           .DW
hcbcls          .DW
hcbx            .DW
hcby            .DW
tmpp    .EQU    hlast   ; temp. long pointer
tmpx    .EQU    hcbx
wild    .EQU    hcbx+1
fsiz    .EQU    hcby
fptr    .EQU    hcby+1
ldrv    .EQU    hcbx
tmpldt  .EQU    hcbx+1

fhash           .DW
fcbofs          .DW
bcbload         .DB
xstart          .DB
xend            .DB
seccnt          .DB
maxseq          .DB
dsiz            .DB

haswld          .DB
strix           .DB
pathp           LP              ; long pointer to path string

; TEMP
quot            .DW
dvsor           .DW
troot           .DW
tlst            .DW
bdmask          .DW
bcmask          .DW

hcbuse          .DB

.ENDS

.LIST off