Portability harness





The file %FileSysDir%\Harness.fth provides portability and architecture specific definitions for the file system.




Miscellaneous

: y/n?          \ -- flag
Wait for a key, echo it and return true if it was a 'Y'.

Synonym .hex .dword     \ n --
Display n as an 8 digit hex number.

: .decimal      ( n -- )        base @ swap  decimal  0 .r  base !  ;
Display in decimal.

2 field-type short      \ n -- n+2 ; addr -- addr+n
Defines a 2-byte field in a structure definition.




Little Endian memory operations

These words are usually implmented as compiler macros, and are provided for interchange of storage media between big and little endian media. They are also necessary when using CompactFlash, ATA or ATAPI drives to avoid endian and data alignment problems.

: c!(le)        \ b caddr --
Little endian byte store.

: w!(le)        \ w caddr --
Little endian 16 bit unaligned word store.

: l!(le)        \ x caddr --
Little endian 32 bit unaligned store.

: c@(le)        \ caddr -- b
Little endian byte fetch.

: w@(le)        \ caddr -- w
Little endian unaligned 16 bit word fetch.

: l@(le)        \ caddr -- x
Little endian unaligned 32 bit word fetch.

: w!(le)        \ w caddr --
Little endian 16 bit unaligned word store.

: l!(le)        \ x caddr --
Little endian 32 bit unaligned store.

: c@(le)        \ caddr -- b
Little endian byte fetch.

: w@(le)        \ caddr -- w
Little endian unaligned 16 bit word fetch.

: l@(le)        \ caddr -- x
Little endian unaligned 32 bit word fetch.




File system data

variable lseconds       \ -- addr
Holds UNIX LSECONDS since ...

cell +user DIR-BLOCK    \ -- addr
Pointer to a directory block.

cell +user *CWD         \ -- addr
Pointer to current work directory name structure.

semaphore drive-access  \ -- addr
Interlock for access to the low level disk driver.

semaphore cache-sema    \ -- addr
Interlock for access to the disk cache software.

semaphore drive-control \ -- addr
Interlock for access to the drive management software.

semaphore fld-update
Interlock for access to the file management software.

: init-sema     \ sema --
Initialise a counted semaphore.




Heap

: allocate      \ u -- addr ior
A redefinition of ALLOCATE that issues a console warning message if it fails.

: free          \ addr -- ior
A redefinition of ALLOCATE that issues a console warning message if it fails.

: ?free         \ addr --
A convenvenient version of FREE that does nothing if addr is zero and does not return an error code.




Strings

: extract-string        \ caddr len char -- caddr' len'
Given a string return the substring between the delimiters, ignoring leading delimiters.

: jump-string   \ caddr len char -- caddr' len'
Ignore leading delimiters, and return the string to the right of the delimiter character including the delimiter.