Implement basic variables (to hide pointers from logs)

This commit is contained in:
Ivan Baravy 2022-05-31 17:43:41 +04:00
parent 20b2013007
commit 5314ef2cae
9 changed files with 505 additions and 280 deletions

700
shell.c

File diff suppressed because it is too large Load Diff

16
shell.h
View File

@ -3,11 +3,27 @@
#include <stdio.h>
enum shell_var_type {
SHELL_VAR_SINT,
SHELL_VAR_UINT,
SHELL_VAR_POINTER,
};
#define SHELL_VAR_NAME_LEN 16
struct shell_var {
struct shell_var *next;
enum shell_var_type type;
char name[SHELL_VAR_NAME_LEN];
union {ssize_t sint; size_t uint; uint64_t uint64; void *ptr;} value;
};
struct shell_ctx {
FILE *fin;
FILE *fout;
int reproducible;
const char *hist_file;
struct shell_var *var;
};
void *run_test(struct shell_ctx *ctx);

View File

@ -7,13 +7,17 @@ status: 0
/>
/> load_cursor_from_file /sys/fill.cur
handle = non-zero
/> var $cur_fill
/> load_cursor_from_mem ../spray.cur
handle = non-zero
/> var $cur_spray
/>
/> window_redraw 1
/> draw_window 10 300 5 200 0x000088 1 1 1 0 1 4 hello
/> window_redraw 2
/>
/> set_cursor $cur_fill
prev handle = non-zero
/>
/>
/> scrot 051_#draw_#cursor_all.out.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -4,12 +4,15 @@ ramdisk_init ../img/kolibri.img
set_skin /sys/DEFAULT.SKN
load_cursor_from_file /sys/fill.cur
var $cur_fill
load_cursor_from_mem ../spray.cur
var $cur_spray
window_redraw 1
draw_window 10 300 5 200 0x000088 1 1 1 0 1 4 hello
window_redraw 2
set_cursor $cur_fill
scrot 051_#draw_#cursor_all.out.png

View File

@ -316,7 +316,7 @@ macro cmp target, source {
cmp target, [esp]
pop eax eax
else
mov target, source
cmp target, source
end if
}
@ -348,7 +348,9 @@ free_page equ free_page_pew
include 'core/memory.inc'
restore map_io_mem, free_page, create_trampoline_pgmap, alloc_page, alloc_pages
;include 'core/mtrr.inc'
;user_alloc_at equ user_alloc_at_pew
include 'core/heap.inc'
;restore user_alloc_at
include 'core/malloc.inc'
macro mov target, source {
if target eq [edi - 4096 + (page_tabs shr 20)]
@ -529,6 +531,8 @@ proc umka_init c uses ebx esi edi ebp
xor eax, eax
rep stosb
; call mem_test
; call init_mem
; call init_page_map
mov [xsave_area_size], 0x1000
@ -851,6 +855,11 @@ proc map_io_mem _base, _size, _flags
ret
endp
;proc user_alloc_at stdcall, address:dword, alloc_size:dword
; xor eax, eax
; ret
;endp
extrn system_shutdown
sysfn_saveramdisk:
@ -941,13 +950,23 @@ macro pew x {inclu#de `x}
macro org x {}
macro format [x] {}
bios32_entry equ bios32_entry_pew
tmp_page_tabs equ tmp_page_tabs_pew
include 'kernel.asm'
restore bios32_entry, tmp_page_tabs
purge org,sys_msg_board,delay_ms
restore org,sys_msg_board,delay_ms
coverage_end:
section '.data.boot' writeable align 0x1000
BOOT boot_data
virtual at BOOT
BOOT_LO boot_data
end virtual
if HOST eq windows
section '.data.8k' writeable align 8192
else if HOST eq linux
@ -962,11 +981,6 @@ pubsym umka_initialized
umka_initialized dd 0
fpu_owner dd ?
BOOT boot_data
virtual at BOOT
BOOT_LO boot_data
end virtual
uglobal
align 64
os_base: rb PAGE_SIZE
@ -994,6 +1008,10 @@ HEAP_BASE rb UMKA_MEMORY_BYTES - (HEAP_BASE - os_base + \
endg
uglobal
align 4
bios32_entry dd ?
tmp_page_tabs dd ?
page_tabs:
rb 256*1024*1024
v86_irqhooks rd IRQ_RESERVED*2

2
umka.h
View File

@ -728,7 +728,7 @@ typedef struct {
extern display_t kos_display;
typedef struct {
void *addr;
uint64_t addr;
uint64_t size;
uint32_t type;
} e820entry_t;

14
umka.ld
View File

@ -17,7 +17,17 @@ INSERT BEFORE .interp;
SECTIONS
{
.data.aligned BLOCK(65536) :
.data.boot BLOCK(0x1000) :
{
*(.data.boot)
}
}
INSERT BEFORE .data;
SECTIONS
{
.data.aligned BLOCK(0x10000) :
{
*(SORT_BY_NAME(.data.align*))
}
@ -27,7 +37,7 @@ INSERT AFTER .data;
SECTIONS
{
.bss.aligned BLOCK(65536) :
.bss.aligned BLOCK(0x10000) :
{
*(SORT_BY_NAME(.bss.align*))
}

View File

@ -40,9 +40,11 @@ void build_history_filename() {
sprintf(history_filename, "%s/%s", dir_name, HIST_FILE_BASENAME);
}
/*
uint8_t mem0[64*1024*1024];
uint8_t mem1[128*1024*1024];
uint8_t mem2[256*1024*1024];
*/
int
main(int argc, char **argv) {
@ -56,14 +58,14 @@ main(int argc, char **argv) {
" -c collect coverage";
const char *infile = NULL, *outfile = NULL;
struct shell_ctx ctx = {.fin = stdin, .fout = stdout, .reproducible = 0,
.hist_file = history_filename};
.hist_file = history_filename, .var = NULL};
build_history_filename();
/*
kos_boot.memmap_block_cnt = 3;
kos_boot.memmap_blocks[0] = (e820entry_t){mem0, 64*1024*1024, 1};
kos_boot.memmap_blocks[1] = (e820entry_t){mem1, 128*1024*1024, 1};
kos_boot.memmap_blocks[2] = (e820entry_t){mem2, 256*1024*1024, 1};
kos_boot.memmap_blocks[0] = (e820entry_t){(uintptr_t)mem0, 64*1024*1024, 1};
kos_boot.memmap_blocks[1] = (e820entry_t){(uintptr_t)mem1, 128*1024*1024, 1};
kos_boot.memmap_blocks[2] = (e820entry_t){(uintptr_t)mem2, 256*1024*1024, 1};
*/
kos_boot.bpp = 32;
kos_boot.x_res = UMKA_DEFAULT_DISPLAY_WIDTH;
kos_boot.y_res = UMKA_DEFAULT_DISPLAY_HEIGHT;