mirror of
https://gitlab.os-k.eu/os-k-team/kvisc.git
synced 2023-08-25 14:05:46 +02:00
memdev
This commit is contained in:
parent
0868c178bc
commit
e9a26fa24b
4
Makefile
4
Makefile
@ -6,7 +6,7 @@ all: kas
|
||||
kpc:
|
||||
@cd vm && make --no-print-directory verbose=no
|
||||
|
||||
kas: kpc as/k-as.py as/regs.lst
|
||||
kas: kpc as/k-as.py as/regs.lst as/
|
||||
@cp vm/in/instrs.lst as
|
||||
|
||||
DOSK = $(shell find ka -name '*.k')
|
||||
@ -16,7 +16,7 @@ vm/a.out: $(DOSK)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@cd vm && make clean
|
||||
@cd vm && make clean --no-print-directory
|
||||
@rm -f vm/a.out vm/k.exe vm/stdout.txt as/instrs.lst
|
||||
|
||||
test: kas vm/a.out
|
||||
|
@ -32,7 +32,7 @@ all: k.exe
|
||||
$(OBJDIR)/%.o: %.c
|
||||
@mkdir -p $(shell dirname $@)
|
||||
@cc $(FLAGS) -c $< -o $@
|
||||
@if true || [ $(verbose) = "yes" ]; then \
|
||||
@if [ $(verbose) = "yes" ]; then \
|
||||
echo ${CL2}[$@] ${CL}object file generated.${CL3};\
|
||||
fi
|
||||
|
||||
@ -47,7 +47,7 @@ in/instrs.lst: in/INSTRS in/arch_i.py
|
||||
@cd in && python3 arch_i.py
|
||||
|
||||
clean:
|
||||
@rm -f $(OBJDIR)/*/*.o in/arch_i.h
|
||||
@rm -f $(OBJDIR)/*/*.o in/arch_i.h in/instrs.lst
|
||||
@rm -f $(OBJDIR)/*/*.d
|
||||
|
||||
k.exe: in/instrs.lst $(obj)
|
||||
|
@ -1,7 +1,7 @@
|
||||
// The OS/K Team licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#include <dv/dev.h>
|
||||
#include <pc/dev.h>
|
||||
|
||||
long cpudev_testfn(ctx_t *ctx, dev_t *dev)
|
||||
{
|
||||
@ -30,9 +30,9 @@ dev_t cpudev =
|
||||
.modl = "Prisma 1",
|
||||
.vend = "The OS/K Team",
|
||||
|
||||
.major = 0,
|
||||
.minor = 1,
|
||||
.revis = 0,
|
||||
.major = KARCH_MAJOR,
|
||||
.minor = KARCH_MINOR,
|
||||
.revis = KARCH_REVIS,
|
||||
|
||||
.fpwon = cpudev_poweron,
|
||||
};
|
26
vm/dv/memdev.c
Normal file
26
vm/dv/memdev.c
Normal file
@ -0,0 +1,26 @@
|
||||
// The OS/K Team licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#include <pc/dev.h>
|
||||
|
||||
long memdev_poweron(ctx_t *ctx, dev_t *dev)
|
||||
{
|
||||
dev->state = DEVGOOD;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
dev_t memdev =
|
||||
{
|
||||
.type = "ram",
|
||||
.name = "K-RAM",
|
||||
.modl = "",
|
||||
.vend = "The OS/K Team",
|
||||
|
||||
.major = KARCH_MAJOR,
|
||||
.minor = KARCH_MINOR,
|
||||
.revis = KARCH_REVIS,
|
||||
|
||||
.fpwon = memdev_poweron,
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
// The OS/K Team licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#include <dv/dev.h>
|
||||
#include <pc/dev.h>
|
||||
#include <in/instrs.h>
|
||||
|
||||
//
|
@ -32,7 +32,6 @@ They consist of the following functions:
|
||||
3 ptr Write device vendor into buffer
|
||||
4 rax=major, rdx=minor
|
||||
5 rax=feats, rdx=revis
|
||||
6-31 (reserved)
|
||||
|
||||
The slots for "iocall" are device-defined. (They correspond
|
||||
to the "fslots" array of the dev_t structure.) See that
|
@ -35,6 +35,10 @@ typedef struct dev_t dev_t;
|
||||
void log(const char *, ...);
|
||||
void vlog(const char *, va_list);
|
||||
|
||||
#define KARCH_MAJOR 0
|
||||
#define KARCH_MINOR 1
|
||||
#define KARCH_REVIS 0
|
||||
|
||||
struct ctx_t
|
||||
{
|
||||
reg_t *r;
|
||||
|
@ -1,9 +1,50 @@
|
||||
// The OS/K Team licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#include <dv/dev.h>
|
||||
#include <pc/dev.h>
|
||||
|
||||
static_assert(sizeof(dev_t) % 8 == 0, "");
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
//
|
||||
// Add new builtin devices here
|
||||
//
|
||||
|
||||
extern dev_t cpudev, memdev;
|
||||
|
||||
static dev_t *arch_d[] =
|
||||
{
|
||||
&cpudev,
|
||||
&memdev,
|
||||
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
||||
int devinitall(ctx_t *ctx)
|
||||
{
|
||||
size_t it;
|
||||
|
||||
for (it = 0; arch_d[it] != NULL; it++) {
|
||||
// log("Adding device %s\n", arch_d[it]->name);
|
||||
if (devinit(ctx, arch_d[it]) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int devfiniall(ctx_t *ctx)
|
||||
{
|
||||
int failed = 0;
|
||||
|
||||
while (ctx->dh)
|
||||
if (devfini(ctx, ctx->dh) < 0)
|
||||
failed = -1;
|
||||
|
||||
return failed;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
dev_t *devalloc(void)
|
||||
{
|
||||
@ -17,6 +58,8 @@ void devfree(dev_t *dev)
|
||||
free(dev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
dev_t *devget(ctx_t *ctx, int idx)
|
||||
{
|
||||
if (idx < 0)
|
||||
@ -65,6 +108,8 @@ int devinit(ctx_t *ctx, dev_t *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// NEVER detach while some assembly code
|
||||
// may still be running on the vm!
|
||||
void devdetach(ctx_t *ctx, dev_t *dev)
|
||||
@ -109,20 +154,3 @@ err:
|
||||
devdetach(ctx, dev);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int devinitall(ctx_t *ctx)
|
||||
{
|
||||
return devinit(ctx, &cpudev);
|
||||
}
|
||||
|
||||
int devfiniall(ctx_t *ctx)
|
||||
{
|
||||
int failed = 0;
|
||||
|
||||
while (ctx->dh)
|
||||
if (devfini(ctx, ctx->dh) < 0)
|
||||
failed = -1;
|
||||
|
||||
return failed;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// The OS/K Team licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#include <dv/dev.h>
|
||||
#include <pc/dev.h>
|
||||
#include <termio.h>
|
||||
|
||||
void _except(ctx_t *ctx, int code, char *fmt, ...)
|
||||
|
@ -2,7 +2,7 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#include <signal.h>
|
||||
#include <dv/dev.h>
|
||||
#include <pc/dev.h>
|
||||
#include <sys/time.h>
|
||||
#include <termio.h>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user