1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00
This commit is contained in:
julianb0 2019-06-14 16:47:01 +02:00
parent 88cd996041
commit d13da7b480
No known key found for this signature in database
GPG Key ID: DDF8325C95299A62
22 changed files with 103 additions and 63 deletions

View File

@ -1,5 +1,5 @@
; 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 "fmt/itoa.k"
include "crt/fmt/itoa.k"

9
ka/crt/str/string.k Normal file
View File

@ -0,0 +1,9 @@
; 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 "crt/str/strlen.k"
include "crt/str/strrev.k"
include "crt/str/strcpy.k"
include "crt/str/strcmp.k"
include "crt/str/strchr.k"

View File

@ -42,10 +42,15 @@ STRLEN_MAX := 0xFFFFFFFF
;
; Include librairies
;
include "err/errno.k"
include "fmt/format.k"
include "prn/print.k"
include "str/string.k"
include "crt/err/errno.k"
include "crt/fmt/format.k"
include "crt/prn/print.k"
include "crt/str/string.k"
;
; Include drivers
;
include "sys/memdev.k"
;
; Disk Operating System

View File

@ -5,8 +5,13 @@
; Main function
;
main:
mov rbx, 10
lea rax, b[rbx + -1]
jmp ramdev_test
ramdev_test:
call DevGetMemOff
mov rdx, rax
call DevGetMemSize
ret
stosb_test:
@ -70,8 +75,6 @@ itoa_test:
.buf = [32]
devtest:
enter
mov ax0, .buf
devctl 0, 1
@ -80,7 +83,6 @@ devtest:
iocall 0, 0
leave
ret
.buf = [32]
@ -127,13 +129,3 @@ str_test:
.buf1 = [32]
.buf2 = "!!!!!!!!!!!!!"
;
; Exit function
;
exit:
mov ax0, .msg
call print
ret
.msg = "Goodbye World :(\n"

View File

@ -1,9 +0,0 @@
; 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 "str/strlen.k"
include "str/strrev.k"
include "str/strcpy.k"
include "str/strcmp.k"
include "str/strchr.k"

16
ka/sys/memdev.k Normal file
View File

@ -0,0 +1,16 @@
; The OS/K Team licenses this file to you under the MIT license.
; See the LICENSE file in the project root for more information.
MEMDEV := 1
MEMDEV_GETMEMOFF := 0
MEMDEV_GETMEMSIZE := 1
DevGetMemOff:
iocall MEMDEV, MEMDEV_GETMEMOFF
ret
DevGetMemSize:
iocall MEMDEV, MEMDEV_GETMEMSIZE
ret

View File

@ -3,8 +3,25 @@
#include <pc/dev.h>
long memdev_getmemoff(ctx_t *ctx, dev_t *dev)
{
rax = MEMOFF;
return 0;
}
long memdev_getmemsize(ctx_t *ctx, dev_t *dev)
{
rax = ctx->mz;
return 0;
}
long memdev_poweron(ctx_t *ctx, dev_t *dev)
{
dev->fslots[0] = memdev_getmemoff;
dev->fslots[1] = memdev_getmemsize;
dev->state = DEVGOOD;
return 0;

View File

@ -26,10 +26,10 @@ The return value in rax is a status value:
The slots for "devctl" are architecture-rerserved.
They consist of the following functions:
Slot Param (ax0) Description
0 ptr Write device type into buffer
1 ptr Write device name into buffer
2 ptr Write device model into buffer
3 ptr Write device vendor into buffer
0 ptr Write device type into 32-bytes buffer
1 ptr Write device name into 32-bytes buffer
2 ptr Write device model into 32-bytes buffer
3 ptr Write device vendor into 32-bytes buffer
4 rax=major, rdx=minor
5 rax=feats, rdx=revis

View File

@ -46,17 +46,18 @@
<pattern-item _name="Instructions" style="def:keyword" case-sensitive="FALSE"
match-empty-string-at-beginning = "TRUE"
match-empty-string-at-end = "TRUE">
<regex>^\s+[a-zA-Z0-9_.$%]{2,}</regex>
<regex>^\s+[a-zA-Z0-9_.$%]{1,}</regex>
</pattern-item>
<keyword-list _name="Registers K" style="def:type"
case-sensitive="FALSE"
match-empty-string-at-beginning = "TRUE"
match-empty-string-at-end = "TRUE">
<keyword>%%?[a-z][a-z0-9.]+</keyword>
<keyword>(inv|flg)</keyword>
<keyword>r[isb]p</keyword>
<keyword>r[isdb]p</keyword>
<keyword>r[a-fs][xi]</keyword>
<keyword>[an]x[0-9]+</keyword>
<keyword>[a-z]x[0-9]+</keyword>
<keyword>(sa|cr)[0-9]+</keyword>
</keyword-list>

View File

@ -87,21 +87,8 @@ void _except(ctx_t *, int, char *, ...) __attribute__((__noreturn__));
void decode(ctx_t *ctx);
#define MEMOFF (1 * 1024 * 1024)
#define MEMSIZE (16 * 1024 * 1024) // 16MB
#define addr2real(p) (((p) - MEMOFF) / 2)
#define real2addr(p) (((p) + MEMOFF) / 2)
// Address of boot firmware stack
#define FWSTACK (MEMOFF * 2) // 2MB
ulong readmem(ctx_t *c, ulong addr, uint len);
void writemem(ctx_t *, ulong val, ulong addr, uint len);
ulong readmemzx(ctx_t *c, ulong addr, uint len);
void writememzx(ctx_t *, ulong val, ulong addr, uint len);
#include <pc/mem.h>
#include <pc/regs.h>
#include <pc/decd.h>
#include <in/arch_i.h>

View File

@ -57,5 +57,3 @@ int devfini(ctx_t *, dev_t *);
int devinitall(ctx_t *);
int devfiniall(ctx_t *);
extern dev_t cpudev;

View File

@ -21,7 +21,13 @@ static void dump_acc(ctx_t *ctx, acc_t *p)
log("%s", ctx->r[p->reg].name);
else if (p->type == A_IMM64)
{
if (p->val < 0xA)
log("%lu", p->val);
else
log("0x%lX", p->val);
}
else
{

17
vm/pc/mem.h Normal file
View File

@ -0,0 +1,17 @@
// The OS/K Team licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#define MEMOFF (1 * 1024 * 1024)
#define MEMSIZE (16 * 1024 * 1024) // 16MB
#define addr2real(p) (((p) - MEMOFF) / 2)
#define real2addr(p) (((p) + MEMOFF) / 2)
// Address of boot firmware stack
#define FWSTACK (MEMOFF * 2) // 2MB
ulong readmem(ctx_t *c, ulong addr, uint len);
void writemem(ctx_t *, ulong val, ulong addr, uint len);
ulong readmemzx(ctx_t *c, ulong addr, uint len);
void writememzx(ctx_t *, ulong val, ulong addr, uint len);

View File

@ -108,13 +108,14 @@ void dumpregs(ctx_t *ctx)
DUMPREGS(SA0, SA3);
DUMPREGS(CR0, CR3);
log("\nrip=0x%-16lX rsp=0x%-16lX rbp=0x%-16lX flg=0x%-16lX\n",
log("\n\nrip=0x%-16lX rsp=0x%-16lX rbp=0x%-16lX flg=0x%-16lX\n\n",
rip, rsp, rbp, flg);
log("\nCF=%-4x OF=%-4x "
"ZF=%-4x SF=%-4x\n"
"PF=%-4x DF=%-4x "
"IF=%-4x UF=%-4x\n",
log("CF=%x OF=%x\n"
"ZF=%x SF=%x\n"
"PF=%x DF=%x\n"
"IF=%x UF=%x\n",
!!(flg&CF), !!(flg&OF),
!!(flg&ZF), !!(flg&SF),
!!(flg&PF), !!(flg&DF),