9os

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

commit a13c2f1424a23920f1570ca15c89d92f80ee6cad
parent 55f6f3f74765b79a4fba792c4aa762492cc5d3b0
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 21 Oct 2020 07:44:04 +0200

os9: Update host mode

After the last changes neede for arm64, the host mode
was generating errors in the compilation. This patch
solves them.

Change-Id: I30cefbd1bd2ed4eb21c545198becd40ff59efa28

Diffstat:
Minclude/bits/amd64/arch/types.h | 6++++++
Minclude/os9/os9.h | 4+++-
Msrc/os9/alloc.c | 3---
Msrc/os9/dev/devblk.c | 12++++++------
Msrc/os9/hosted/main.c | 33+++++++++++++--------------------
Msrc/os9/sched.c | 2+-
6 files changed, 29 insertions(+), 31 deletions(-)

diff --git a/include/bits/amd64/arch/types.h b/include/bits/amd64/arch/types.h @@ -1,2 +1,8 @@ +struct context { + unsigned long long regs[1]; +}; + typedef int atomic_t; typedef unsigned long mutex_t; +typedef unsigned long long phyaddr_t; +typedef struct context Context; diff --git a/include/os9/os9.h b/include/os9/os9.h @@ -15,9 +15,11 @@ #endif #define NR_TASKS 16 -#define NR_PROCS 32 #define NR_WINS 32 +#define NR_BUFFERS 512 +#define HEAPSIZ (4 * PAGESIZE) + #define KiB 1024u #define MiB (1024u * KiB) #define GiB (1024ul * MiB) diff --git a/src/os9/alloc.c b/src/os9/alloc.c @@ -2,9 +2,6 @@ #include <string.h> -#define NR_BUFFERS 512 -#define HEAPSIZ (4 * PAGESIZE) - union bucket { long long ll; uintptr_t up; diff --git a/src/os9/dev/devblk.c b/src/os9/dev/devblk.c @@ -7,7 +7,7 @@ #include "dev.h" #include "blk.h" -#define NR_BUFFERS 1 +#define NR_BLOCKS 1 #define NR_BLKS 2 typedef struct buffer Buffer; @@ -33,8 +33,8 @@ struct buffer { mutex_t mutex; }; -static char buffers[NR_BUFFERS][BLKSIZ]; -static Buffer bcache[NR_BUFFERS]; +static char buffers[NR_BLOCKS][BLKSIZ]; +static Buffer bcache[NR_BLOCKS]; static Dirtab dirtab[] = { {"raw", QID(CHFILE, 0, Qraw), 0, O_READ | O_WRITE}, @@ -59,7 +59,7 @@ blkstat(Chan *c, char *file, unsigned char *buf, int n) static Buffer * getblk(int devno, long blkno) { - Buffer *bp = &bcache[blkno % NR_BUFFERS]; + Buffer *bp = &bcache[blkno % NR_BLOCKS]; Blk *dev; repeat: @@ -234,7 +234,7 @@ blksync(Chan *c, int what) Buffer *bp; int r = 0; - for (bp = bcache; bp < &bcache[NR_BUFFERS]; ++bp) { + for (bp = bcache; bp < &bcache[NR_BLOCKS]; ++bp) { lock(&bp->mutex); if ((bp->flags & BDIRTY) != 0 && @@ -269,7 +269,7 @@ blklink(Blkphy *phy, Attr *attr) int i; Buffer *bp; - for (i = 0; i < NR_BUFFERS; i++) { + for (i = 0; i < NR_BLOCKS; i++) { bp = &bcache[i]; bp->ptr = buffers[i]; bp->flags = 0; diff --git a/src/os9/hosted/main.c b/src/os9/hosted/main.c @@ -11,6 +11,9 @@ noreturn void longjmp(jmp_buf env, int val); Chan *console; +char buffertab[NR_BUFFERS][PAGESIZE]; + +Mach mach; int getch(void) @@ -52,31 +55,21 @@ imach(void) exit(EXIT_FAILURE); } -static void -icons(void) +char * +getconf(char *name) { - static char setin[] = "addin #t0/raw\n"; - static char setout[] = "addout #t0/raw\n"; - Chan *c; - - if ((c = devopen("#c/ctl", O_WRITE)) <0) - panic("namec:/dev/cons/ctl write"); - if (devwrite(c, setin, sizeof(setin)) < 0) - panic("write:setin"); - if (devwrite(c, setout, sizeof(setout)) < 0) - panic("write:setout"); - if (devclose(c) < 0) - panic("write:setout"); - - if ((console = devopen("#c/raw", O_RDWR)) < 0) - panic("devopen:#c/raw read"); + static char constxt[] = + "addin #t0/raw\n" + "addout #t0/raw\n"; + + return constxt; } int main(int argc, char *argv[]) { imach(); - idev(); - icons(); - debug(); + isys(); + + return 0; } diff --git a/src/os9/sched.c b/src/os9/sched.c @@ -31,7 +31,7 @@ gettask(int tid) { Task *tp; - for (tp = tasktab; tp < &tasktab[NR_PROCS]; ++tp) { + for (tp = tasktab; tp < &tasktab[NR_TASKS]; ++tp) { if (tp->mode != PDISABLED && tp->tid == tid) return tp; }