1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-17 10:38:05 +11:00
collapseos/kernel/mmap.asm
Virgil Dupras b745f49186 Rename blockdev's API routines to GetB/PutB
The goal is to avoid mixing those routines with "character devices"
(acia, vpd, kbd) which aren't block devices and have routines that
have different expectations.

This is a first step to fixing #64.
2019-10-30 16:59:35 -04:00

47 lines
736 B
NASM

; mmap
;
; Block device that maps to memory.
;
; *** DEFINES ***
; MMAP_START: Memory address where the mmap begins
; Memory address where the mmap stops, exclusively (we aren't allowed to access
; that address).
.equ MMAP_LEN 0xffff-MMAP_START
; Returns absolute addr of memory pointer in HL if HL is within bounds.
; Sets Z on success, unset when out of bounds.
_mmapAddr:
push de
ld de, MMAP_LEN
call cpHLDE
jr nc, .outOfBounds ; HL >= DE
ld de, MMAP_START
add hl, de
cp a ; ensure Z
pop de
ret
.outOfBounds:
pop de
jp unsetZ
mmapGetB:
push hl
call _mmapAddr
jr nz, .end
ld a, (hl)
; Z already set
.end:
pop hl
ret
mmapPutB:
push hl
call _mmapAddr
jr nz, .end
ld (hl), a
; Z already set
.end:
pop hl
ret