9os

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit c2503d5ce25019d215787d2a198f01d98c837491
parent ccb01550ccd794bb7c833ba144f45e374e9f0871
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat,  7 Aug 2021 07:42:28 +0200

os9/arm64: Move imach() and getch()

This code is generic and can be reused by other systems
because it does not have any code specific to FVP.

Change-Id: Iaa2a36b58a4af285d2ee48340f9120babd955de9

Diffstat:
Msrc/os9/arch/arm64/arch.h | 1+
Msrc/os9/arch/arm64/fvp.c | 49-------------------------------------------------
Msrc/os9/arch/arm64/main.c | 49+++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 49 deletions(-)

diff --git a/src/os9/arch/arm64/arch.h b/src/os9/arch/arm64/arch.h @@ -36,3 +36,4 @@ extern void igic(void); /* globals */ extern int inlowmem; +extern Mach mach; diff --git a/src/os9/arch/arm64/fvp.c b/src/os9/arch/arm64/fvp.c @@ -14,55 +14,6 @@ Mach mach = { }; void -imach(void) -{ - Map *textp, *datap, *stackp, *pagep; - static Map maps[5]; - extern char text[], etext[], end[]; - - mach.maps = maps; - textp = &maps[0]; - datap = &maps[1]; - stackp = &maps[2]; - pagep = &maps[3]; - - textp->name = "text"; - textp->pa = mach.phytext; - textp->va = mach.phytext + mach.kzero; - textp->siz = etext - text; - textp->perm = MR | MX; - - datap->name = "data"; - datap->pa = textp->pa +textp->siz; - datap->va = datap->pa + mach.kzero; - datap->siz = end - etext; - datap->perm = MR | MW; - - stackp->name = "stack"; - stackp->pa = mach.phystack - PAGESIZE; - stackp->va = datap->va + datap->siz + PAGESIZE; - stackp->siz = PAGESIZE; - stackp->perm = MR | MW; - - pagep->name = "ptable"; - pagep->pa = mach.phystack; - pagep->va = 0xFFFFFF0000080000; - pagep->siz = PAGESIZE * 20; - pagep->perm = MR | MW; -} - -int -getch(void) -{ - char ch; - - if (!console) - panic("getch out of sync"); - devread(console, &ch, 1); - return ch; -} - -void putch(int c) { char ch; diff --git a/src/os9/arch/arm64/main.c b/src/os9/arch/arm64/main.c @@ -26,6 +26,55 @@ getconf(char *name) return constxt; } +int +getch(void) +{ + char ch; + + if (!console) + panic("getch out of sync"); + devread(console, &ch, 1); + return ch; +} + +void +imach(void) +{ + Map *textp, *datap, *stackp, *pagep; + static Map maps[5]; + extern char text[], etext[], end[]; + + mach.maps = maps; + textp = &maps[0]; + datap = &maps[1]; + stackp = &maps[2]; + pagep = &maps[3]; + + textp->name = "text"; + textp->pa = mach.phytext; + textp->va = mach.phytext + mach.kzero; + textp->siz = etext - text; + textp->perm = MR | MX; + + datap->name = "data"; + datap->pa = textp->pa +textp->siz; + datap->va = datap->pa + mach.kzero; + datap->siz = end - etext; + datap->perm = MR | MW; + + stackp->name = "stack"; + stackp->pa = mach.phystack - PAGESIZE; + stackp->va = datap->va + datap->siz + PAGESIZE; + stackp->siz = PAGESIZE; + stackp->perm = MR | MW; + + pagep->name = "ptable"; + pagep->pa = mach.phystack; + pagep->va = 0xFFFFFF0000080000; + pagep->siz = PAGESIZE * 20; + pagep->perm = MR | MW; +} + void main(Mach *m) {