From 57fadae3dd35055c2747f2d733a0d1cb264d497e Mon Sep 17 00:00:00 2001 From: Ivan Baravy Date: Mon, 11 May 2020 06:38:44 +0300 Subject: [PATCH] Add background related functions; umka_os works. --- linux/thread.c | 6 +- shell.c | 108 +++++++++++++++++++- test/016_#f01_#draw_all.ref.log | 21 ++-- test/016_#f01_#draw_all.ref.png | Bin 3841 -> 2824 bytes test/016_#f01_#draw_all.t | 13 +-- umka.asm | 176 ++++++++++++++++---------------- umka.h | 82 +++++++++++++++ umka_fuse.c | 61 +++++++---- umka_os.c | 12 +-- umka_shell.c | 1 + 10 files changed, 331 insertions(+), 149 deletions(-) diff --git a/linux/thread.c b/linux/thread.c index e201209..e84eca4 100644 --- a/linux/thread.c +++ b/linux/thread.c @@ -8,8 +8,8 @@ sigjmp_buf trampoline; __attribute__((__stdcall__)) uint32_t umka_sched_add_thread(appdata_t *app) { - fprintf(stderr, "umka_new_sys_threads before\n"); - fprintf(stderr, "kos_task_count: %d\n", kos_task_count); +// fprintf(stderr, "umka_new_sys_threads before\n"); +// fprintf(stderr, "kos_task_count: %d\n", kos_task_count); if (!sigsetjmp(trampoline, 1)) { __asm__ __inline__ __volatile__ ( "pushfd;" @@ -29,7 +29,7 @@ uint32_t umka_sched_add_thread(appdata_t *app) { : "memory"); } } - fprintf(stderr, "umka_new_sys_threads after\n"); +// fprintf(stderr, "umka_new_sys_threads after\n"); return 0; } diff --git a/shell.c b/shell.c index 5338d7c..88d59c2 100644 --- a/shell.c +++ b/shell.c @@ -201,6 +201,7 @@ void prompt() { fflush(fout); } +/* # define __FD_ZERO(fdsp) \ do { \ int __d0, __d1; \ @@ -211,7 +212,7 @@ void prompt() { "1" (&__FDS_BITS (fdsp)[0]) \ : "memory"); \ } while (0) - +*/ int next_line(int is_tty, int block) { if (is_tty) { @@ -221,7 +222,8 @@ int next_line(int is_tty, int block) { return fgets(cmd_buf, FGETS_BUF_LEN, fin) != NULL; } else { fd_set readfds; - FD_ZERO(&readfds); +// FD_ZERO(&readfds); + memset(&readfds, 0, sizeof(readfds)); FD_SET(fileno(fin), &readfds); struct timeval timeout = {.tv_sec = 0, .tv_usec = 0}; int sr = select(fileno(fin)+1, &readfds, NULL, NULL, &timeout); @@ -1676,6 +1678,101 @@ fprintf(fout, "## after\n"); } } +void shell_bg_set_size(int argc, char **argv) { + const char *usage = \ + "usage: bg_set_size \n" + " xsize in pixels\n" + " ysize in pixels"; + if (argc != 3) { + puts(usage); + return; + } + uint32_t xsize = strtoul(argv[1], NULL, 0); + uint32_t ysize = strtoul(argv[2], NULL, 0); + umka_sys_bg_set_size(xsize, ysize); +} + +void shell_bg_put_pixel(int argc, char **argv) { + const char *usage = \ + "usage: bg_put_pixel \n" + " offset in bytes, (x+y*xsize)*3\n" + " color in hex"; + if (argc != 3) { + puts(usage); + return; + } + size_t offset = strtoul(argv[1], NULL, 0); + uint32_t color = strtoul(argv[2], NULL, 0); + umka_sys_bg_put_pixel(offset, color); +} + +void shell_bg_redraw(int argc, char **argv) { + (void)argv; + const char *usage = \ + "usage: bg_redraw"; + if (argc != 1) { + puts(usage); + return; + } + umka_sys_bg_redraw(); +} + +void shell_bg_set_mode(int argc, char **argv) { + const char *usage = \ + "usage: bg_set_mode \n" + " mode 1 = tile, 2 = stretch"; + if (argc != 3) { + puts(usage); + return; + } + uint32_t mode = strtoul(argv[1], NULL, 0); + umka_sys_bg_set_mode(mode); +} + +void shell_bg_put_img(int argc, char **argv) { + const char *usage = \ + "usage: bg_put_img \n" + " image file\n" + " offset in bytes, (x+y*xsize)*3\n"; + if (argc != 4) { + puts(usage); + return; + } + FILE *f = fopen(argv[1], "r"); + fseek(f, 0, SEEK_END); + size_t fsize = ftell(f); + rewind(f); + uint8_t *image = (uint8_t*)malloc(fsize); + fread(image, fsize, 1, f); + fclose(f); + size_t offset = strtoul(argv[2], NULL, 0); + umka_sys_bg_put_img(image, offset, fsize); +} + +void shell_bg_map(int argc, char **argv) { + (void)argv; + const char *usage = \ + "usage: bg_map"; + if (argc != 1) { + puts(usage); + return; + } + void *addr = umka_sys_bg_map(); + fprintf(fout, "%p\n", addr); +} + +void shell_bg_unmap(int argc, char **argv) { + const char *usage = \ + "usage: bg_unmap \n" + " addr return value of bg_map"; + if (argc != 2) { + puts(usage); + return; + } + void *addr = (void*)strtoul(argv[1], NULL, 0); + uint32_t status = umka_sys_bg_unmap(addr); + fprintf(fout, "status = %d\n", status); +} typedef struct { char *name; @@ -1758,6 +1855,13 @@ func_table_t funcs[] = { { "net_arp_get_count", shell_net_arp_get_count }, { "net_arp_get_entry", shell_net_arp_get_entry }, { "net_arp_add_entry", shell_net_arp_add_entry }, + { "bg_set_size", shell_bg_set_size }, + { "bg_put_pixel", shell_bg_put_pixel }, + { "bg_redraw", shell_bg_redraw }, + { "bg_set_mode", shell_bg_set_mode }, + { "bg_put_img", shell_bg_put_img }, + { "bg_map", shell_bg_map }, + { "bg_unmap", shell_bg_unmap }, { NULL, NULL }, }; diff --git a/test/016_#f01_#draw_all.ref.log b/test/016_#f01_#draw_all.ref.log index cc08f3d..d68c0ba 100644 --- a/test/016_#f01_#draw_all.ref.log +++ b/test/016_#f01_#draw_all.ref.log @@ -3,7 +3,7 @@ /> set_skin /sys/DEFAULT.SKN status: 0 /> window_redraw 1 -/> draw_window 0 300 0 200 0x000088 1 1 1 0 1 4 hello +/> draw_window 10 300 5 200 0x000088 1 1 1 0 1 4 hello /> set_pixel 0 0 0x0000ff /> set_pixel 1 1 0xff0000 /> set_pixel 2 2 0x00ff00 @@ -21,7 +21,7 @@ status: 0 /> window_redraw 2 /> set_window_caption hi_there 0 -/> move_window 220 35 150 200 + /> get_font_smoothing font smoothing: 2 - subpixel /> set_font_smoothing 0 @@ -41,15 +41,6 @@ font smoothing: 0 - off 0x007e7e7e work_graph /> set_window_colors 0 0 0 0 0 0 0 0 0 0 -/> window_redraw 1 -/> draw_window 0 300 0 200 0x000088 1 1 1 0 1 4 hello -/> set_pixel 0 0 0x0000ff -/> set_pixel 1 1 0xff0000 -/> set_pixel 2 2 0x00ff00 -/> window_redraw 2 - -/> set_window_caption hi_2there 0 - /> dump_win_stack 5 0: 0 1: 1 @@ -67,13 +58,13 @@ font smoothing: 0 - off cpu_usage: 0 window_stack_position: 2 window_stack_value: 2 -process_name: +process_name: OS memory_start: 0x00000000 used_memory: 4294967295 (0xffffffff) -pid: 0 -box: 220 35 150 200 +pid: 8 +box: 10 5 300 200 slot_state: 0 -client_box: 5 24 140 171 +client_box: 5 24 290 171 wnd_state: 0x00 /> get_skin_height 24 diff --git a/test/016_#f01_#draw_all.ref.png b/test/016_#f01_#draw_all.ref.png index c06c98d857fa3acd4514be15d743d874d81d0011..82fe47c402d8f52632444bf90c93726db867ab75 100644 GIT binary patch delta 2257 zcmai$`9D+(AIE1oI3vp$SsGc6V*7EQ8C*{@#DAMkvC`Mkf&=k@*m_~jW1bj23R1OkD>;gr~J zB`)KWNPGa`lgY`8#RUR}VTlwu|$(kAjB9M9WgbHMi3l=(h^9^ zF_}!3kdWZxV@z0B=bBPB+gW%OWlXfUWdN!@B?MoH+M5s znDVCfR(ye<`P`!$9$y*`0DOOAzPjoe2urH*yY|& zS9dQ9={S_8c%uVxEG-H;ckJ{MtMZL4s&p|-oX~&`q+bd)Z z9bu{R1%-V;s_sBc)5NaAq9SWuQGvtgy5-`Nl0Cy0_k8~S-r=PZPt%^%RfTzR9j z^MO{!)Yo^NokO#vHv@JDw<}9Aku*k8HNR=hV|a`cWTt2LW1;wEj<*e`z4ui?hvPXb ziIX%Vqi|!Ae7>!1XsD9Ey1csj?%ibV9lNWmy15gQ=($Vp_8prpS!=$rUw-Ub`)j?L z{*Z#s&-cX%B5%6&b;jVJdA{%Tw4TkL&)79RG5^N%uG;7+1(}?fNG2b&im}OT(clQA)rt013a206|9 zNe;{Q!*uf_yJM+sPuc$jt{r| zN{IgEy9NhrYrgdL1znFAQM^#U=)dq-nZvx(nOfL2%RW^-E5weOnuaqRRnu8^x7{2g z&ch}m_2vtu*Gh<$p1Nxs;hj(LCgqR%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2ZVC2(?7 diff --git a/test/016_#f01_#draw_all.t b/test/016_#f01_#draw_all.t index 0939e35..908d9e1 100644 --- a/test/016_#f01_#draw_all.t +++ b/test/016_#f01_#draw_all.t @@ -1,7 +1,7 @@ disk_add ../img/kolibri.img rd -c 0 set_skin /sys/DEFAULT.SKN window_redraw 1 -draw_window 0 300 0 200 0x000088 1 1 1 0 1 4 hello +draw_window 10 300 5 200 0x000088 1 1 1 0 1 4 hello set_pixel 0 0 0x0000ff set_pixel 1 1 0xff0000 set_pixel 2 2 0x00ff00 @@ -19,7 +19,7 @@ blit_bitmap chess_image.rgba 20 35 8 8 0 0 8 8 0 0 0 1 32 window_redraw 2 set_window_caption hi_there 0 -move_window 220 35 150 200 + get_font_smoothing set_font_smoothing 0 get_font_smoothing @@ -27,15 +27,6 @@ get_font_smoothing get_window_colors set_window_colors 0 0 0 0 0 0 0 0 0 0 -window_redraw 1 -draw_window 0 300 0 200 0x000088 1 1 1 0 1 4 hello -set_pixel 0 0 0x0000ff -set_pixel 1 1 0xff0000 -set_pixel 2 2 0x00ff00 -window_redraw 2 - -set_window_caption hi_2there 0 - dump_win_stack 5 dump_win_pos 5 diff --git a/umka.asm b/umka.asm index ba93d86..46ec2e2 100644 --- a/umka.asm +++ b/umka.asm @@ -3,6 +3,14 @@ format ELF __DEBUG__ = 1 __DEBUG_LEVEL__ = 1 +UMKA_SHELL = 1 +UMKA_FUSE = 2 +UMKA_OS = 3 + +UMKA_MEMORY_BYTES = 128 SHL 20 +UMKA_DISPLAY_WIDTH = 400 +UMKA_DISPLAY_HEIGHT = 300 + public disk_add public disk_del public disk_list @@ -43,6 +51,15 @@ public kos_acpi_ssdt_size public stack_init public net_add_device +public draw_data +public img_background +public BgrDataWidth +public BgrDataHeight +public mem_BACKGROUND +public sys_background +public REDRAW_BACKGROUND +public background_defined + macro cli { pushfd btr dword[esp], 21 @@ -180,13 +197,12 @@ proc kos_init c uses ebx esi edi ebp xor eax, eax rep stosb - MEMORY_BYTES = 128 SHL 20 - DISPLAY_WIDTH = 400 - DISPLAY_HEIGHT = 300 - mov [pg_data.mem_amount], MEMORY_BYTES - mov [pg_data.pages_count], MEMORY_BYTES / PAGE_SIZE - mov [pg_data.pages_free], MEMORY_BYTES / PAGE_SIZE - mov eax, MEMORY_BYTES SHR 12 + mov [xsave_area_size], 0x1000 + + mov [pg_data.mem_amount], UMKA_MEMORY_BYTES + mov [pg_data.pages_count], UMKA_MEMORY_BYTES / PAGE_SIZE + mov [pg_data.pages_free], UMKA_MEMORY_BYTES / PAGE_SIZE + mov eax, UMKA_MEMORY_BYTES SHR 12 mov [pg_data.kernel_pages], eax shr eax, 10 mov [pg_data.kernel_tables], eax @@ -199,9 +215,9 @@ proc kos_init c uses ebx esi edi ebp list_init eax mov [BOOT.bpp], 32 - mov [BOOT.x_res], 400 - mov [BOOT.y_res], 300 - mov [BOOT.pitch], 400*4 + mov [BOOT.x_res], UMKA_DISPLAY_WIDTH + mov [BOOT.y_res], UMKA_DISPLAY_HEIGHT + mov [BOOT.pitch], UMKA_DISPLAY_WIDTH*4 mov [BOOT.lfb], LFB_BASE call init_video @@ -214,30 +230,6 @@ proc kos_init c uses ebx esi edi ebp mov [srv.fd], eax mov [srv.bk], eax - mov dword[sysdir_name], 'sys' - mov dword[sysdir_path], 'RD/1' - mov word[sysdir_path+4], 0 - - mov dword[CURRENT_TASK], 2 - mov dword[TASK_COUNT], 2 - mov dword[TASK_BASE], CURRENT_TASK + 2*sizeof.TASKDATA - mov [current_slot], SLOT_BASE + 256*2 - - ;call ramdisk_init - - mov ebx, SLOT_BASE + 2*256 - stdcall kernel_alloc, 0x2000 - mov [ebx+APPDATA.process], eax - mov word[cur_dir.path], '/' - mov [ebx+APPDATA.cur_dir], cur_dir - mov [ebx+APPDATA.wnd_clientbox.left], 0 - mov [ebx+APPDATA.wnd_clientbox.top], 0 - - mov [X_UNDER], 500 - mov [Y_UNDER], 500 - mov word[MOUSE_X], 40 - mov word[MOUSE_Y], 30 - stdcall kernel_alloc, [_display.win_map_size] mov [_display.win_map], eax @@ -261,43 +253,16 @@ proc kos_init c uses ebx esi edi ebp @@: mov [clipboard_main_list], eax + mov dword[sysdir_name], 'sys' + mov dword[sysdir_path], 'RD/1' + mov word[sysdir_path+4], 0 - call set_window_defaults - call init_background - call calculatebackground - call init_display - mov eax, [def_cursor] - mov [SLOT_BASE+APPDATA.cursor+256], eax - mov [SLOT_BASE+APPDATA.cursor+256*2], eax + ;call ramdisk_init - ; from set_variables - xor eax, eax - mov [BTN_ADDR], dword BUTTON_INFO ; address of button list - mov byte [KEY_COUNT], al ; keyboard buffer - mov byte [BTN_COUNT], al ; button buffer - - ;call load_default_skin - ;call stack_init - - ret -endp - -public skin_udata -proc idle uses ebx esi edi -.loop: - mov ecx, 10000000 -@@: - loop @b - DEBUGF 1, "1 idle\n" - jmp .loop - - ret -endp - -extrn raise -public umka_os -proc umka_os uses ebx esi edi - call kos_init + mov [X_UNDER], 500 + mov [Y_UNDER], 500 + mov word[MOUSE_X], 40 + mov word[MOUSE_Y], 30 mov eax, -1 mov edi, thr_slot_map+4 @@ -315,22 +280,26 @@ proc umka_os uses ebx esi edi mov dword[CURRENT_TASK], 0 mov dword[TASK_COUNT], 0 - stdcall kernel_alloc, RING0_STACK_SIZE + mov eax, [xsave_area_size] + add eax, RING0_STACK_SIZE + stdcall kernel_alloc, eax mov ebx, eax mov edx, SLOT_BASE+256*1 call setup_os_slot - mov dword [edx], 'IDLE' + mov dword[edx], 'IDLE' sub [edx+APPDATA.saved_esp], 4 mov eax, [edx+APPDATA.saved_esp] - mov dword[eax], idle ; _thread + mov dword[eax], idle mov ecx, IDLE_PRIORITY call sched_add_thread - stdcall kernel_alloc, RING0_STACK_SIZE + mov eax, [xsave_area_size] + add eax, RING0_STACK_SIZE + stdcall kernel_alloc, eax mov ebx, eax mov edx, SLOT_BASE+256*2 call setup_os_slot - mov dword [edx], 'OS' + mov dword[edx], 'OS' sub [edx+APPDATA.saved_esp], 4 mov eax, [edx+APPDATA.saved_esp] mov dword[eax], 0 @@ -342,9 +311,45 @@ proc umka_os uses ebx esi edi mov dword[TASK_BASE], CURRENT_TASK + 2*sizeof.TASKDATA mov [current_slot], SLOT_BASE+256*2 -; movi ebx, 1 -; mov ecx, eth_process_input -; call new_sys_threads + call set_window_defaults + call init_background + call calculatebackground + call init_display + mov eax, [def_cursor] + mov [SLOT_BASE+APPDATA.cursor+256], eax + mov [SLOT_BASE+APPDATA.cursor+256*2], eax + + ; from set_variables + xor eax, eax + mov [BTN_ADDR], dword BUTTON_INFO ; address of button list + mov byte [KEY_COUNT], al ; keyboard buffer + mov byte [BTN_COUNT], al ; button buffer + + mov ebx, SLOT_BASE + 2*256 + mov word[cur_dir.path], '/' + mov [ebx+APPDATA.cur_dir], cur_dir + + ;call stack_init + + ret +endp + +public skin_udata +proc idle uses ebx esi edi +.loop: + mov ecx, 10000000 +@@: + loop @b +; DEBUGF 1, "1 idle\n" + jmp .loop + + ret +endp + +extrn raise +public umka_os +proc umka_os uses ebx esi edi + call kos_init call stack_init @@ -368,13 +373,6 @@ proc umka_os uses ebx esi edi jmp osloop -.loop: - mov ecx, 10000000 -@@: - loop @b - DEBUGF 1, "2 os\n" - jmp .loop - ret endp @@ -426,12 +424,14 @@ sched_add_thread: ret change_task: - mov [REDRAW_BACKGROUND], 0 ret public umka_install_thread proc umka_install_thread _func - stdcall kernel_alloc, RING0_STACK_SIZE + 512 ; fpu_state + ; fpu_state = sigsetjmp + mov eax, [xsave_area_size] + add eax, RING0_STACK_SIZE + stdcall kernel_alloc, eax mov ebx, eax mov edx, [TASK_COUNT] inc edx @@ -523,7 +523,6 @@ map_memEx: HEAP_BASE equ include 'init.inc' sys_msg_board equ __pew -;setup_os_slot equ ___pew include fix pew macro pew x {} @@ -555,7 +554,6 @@ macro add r, v { end if } - include 'kernel.asm' purge lea,add,org @@ -566,6 +564,8 @@ coverage_end: section '.data' writeable align 64 +public umka_tool +umka_tool dd ? timer_ticks dd 0 fpu_owner dd ? diff --git a/umka.h b/umka.h index 0f61144..8f8b7d9 100644 --- a/umka.h +++ b/umka.h @@ -469,6 +469,11 @@ typedef struct { uint32_t cpu_usage; } taskdata_t; +#define UMKA_SHELL 1u +#define UMKA_FUSE 2u +#define UMKA_OS 3u + +extern uint32_t umka_tool; extern uint32_t kos_current_task; extern appdata_t *kos_current_slot; extern size_t kos_task_count; @@ -629,6 +634,83 @@ static inline void umka_sys_get_screen_size(uint32_t *xsize, uint32_t *ysize) { *ysize = (xysize & 0xffffu) + 1; } +static inline void umka_sys_bg_set_size(uint32_t xsize, uint32_t ysize) { + __asm__ __inline__ __volatile__ ( + "call i40" + : + : "a"(15), + "b"(1), + "c"(xsize), + "d"(ysize) + : "memory"); +} + +static inline void umka_sys_bg_put_pixel(uint32_t offset, uint32_t color) { + __asm__ __inline__ __volatile__ ( + "call i40" + : + : "a"(15), + "b"(2), + "c"(offset), + "d"(color) + : "memory"); +} + +static inline void umka_sys_bg_redraw() { + __asm__ __inline__ __volatile__ ( + "call i40" + : + : "a"(15), + "b"(3) + : "memory"); +} + +static inline void umka_sys_bg_set_mode(uint32_t mode) { + __asm__ __inline__ __volatile__ ( + "call i40" + : + : "a"(15), + "b"(4), + "c"(mode) + : "memory"); +} + +static inline void umka_sys_bg_put_img(void *image, size_t offset, + size_t size) { + __asm__ __inline__ __volatile__ ( + "call i40" + : + : "a"(15), + "b"(5), + "c"(image), + "d"(offset), + "S"(size) + : "memory"); +} + +static inline void *umka_sys_bg_map() { + void *addr; + __asm__ __inline__ __volatile__ ( + "call i40" + : "=a"(addr) + : "a"(15), + "b"(6) + : "memory"); + return addr; +} + +static inline uint32_t umka_sys_bg_unmap(void *addr) { + uint32_t status; + __asm__ __inline__ __volatile__ ( + "call i40" + : "=a"(status) + : "a"(15), + "b"(7), + "c"(addr) + : "memory"); + return status; +} + static inline void umka_sys_set_cwd(const char *dir) { __asm__ __inline__ __volatile__ ( "call i40" diff --git a/umka_fuse.c b/umka_fuse.c index ca5feb0..4091ecb 100644 --- a/umka_fuse.c +++ b/umka_fuse.c @@ -64,7 +64,14 @@ static int umka_getattr(const char *path, struct stat *stbuf, int res = 0; bdfe_t file; - f7080s5arg_t fX0 = {.sf = 5, .flags = 0, .buf = &file, .u = {.f80 = {.path_encoding = UTF8, .path = path}}}; + f7080s5arg_t fX0 = {.sf = 5, + .flags = 0, + .buf = &file, + .u = {.f80 = {.path_encoding = UTF8, + .path = path + } + } + }; f7080ret_t r; umka_sys_lfn(&fX0, &r, F80); @@ -81,7 +88,16 @@ static int umka_readdir(const char *path, void *buf, fuse_fill_dir_t filler, (void) flags; f7080s1info_t *dir = (f7080s1info_t*)malloc(sizeof(f7080s1info_t) + BDFE_LEN_UNICODE * DIRENTS_TO_READ); - f7080s1arg_t fX0 = {.sf = 1, .offset = 0, .encoding = UTF8, .size = DIRENTS_TO_READ, .buf = dir, .u = {.f80 = {.path_encoding = UTF8, .path = path}}}; + f7080s1arg_t fX0 = {.sf = 1, + .offset = 0, + .encoding = UTF8, + .size = DIRENTS_TO_READ, + .buf = dir, + .u = {.f80 = {.path_encoding = UTF8, + .path = path + } + } + }; f7080ret_t r; umka_sys_lfn(&fX0, &r, F80); bdfe_t *bdfe = dir->bdfes; @@ -94,14 +110,14 @@ static int umka_readdir(const char *path, void *buf, fuse_fill_dir_t filler, } static int umka_open(const char *path, struct fuse_file_info *fi) { -// if (strcmp(path+1, "blah") != 0) -// return -ENOENT; - (void) path; +// if (strcmp(path+1, "blah") != 0) +// return -ENOENT; + (void) path; - if ((fi->flags & O_ACCMODE) != O_RDONLY) - return -EACCES; + if ((fi->flags & O_ACCMODE) != O_RDONLY) + return -EACCES; - return 0; + return 0; } static int umka_read(const char *path, char *buf, size_t size, off_t offset, @@ -115,21 +131,22 @@ static int umka_read(const char *path, char *buf, size_t size, off_t offset, } static struct fuse_operations umka_oper = { - .init = umka_init, - .getattr = umka_getattr, - .readdir = umka_readdir, - .open = umka_open, - .read = umka_read, + .init = umka_init, + .getattr = umka_getattr, + .readdir = umka_readdir, + .open = umka_open, + .read = umka_read, }; int main(int argc, char *argv[]) { - if (argc != 3) { - printf("usage: umka_fuse dir img\n"); - exit(1); - } - kos_init(); - void *userdata = vdisk_init(argv[2], 1, 0u); - void *vdisk = disk_add(&vdisk_functions, "hd0", userdata, 0); - disk_media_changed(vdisk, 1); - return fuse_main(argc-1, argv, &umka_oper, NULL); + umka_tool = UMKA_FUSE; + if (argc != 3) { + printf("usage: umka_fuse dir img\n"); + exit(1); + } + kos_init(); + void *userdata = vdisk_init(argv[2], 1, 0u); + void *vdisk = disk_add(&vdisk_functions, "hd0", userdata, 0); + disk_media_changed(vdisk, 1); + return fuse_main(argc-1, argv, &umka_oper, NULL); } diff --git a/umka_os.c b/umka_os.c index 8a2581c..a6bdb3c 100644 --- a/umka_os.c +++ b/umka_os.c @@ -22,7 +22,6 @@ void scheduler(int signo, siginfo_t *info, void *context) { // printf("##### switching from task %u\n", kos_current_task); ucontext_t *ctx = context; if (!sigsetjmp(*kos_slot_base[kos_current_task].fpu_state, 1)) { -// printf("##### saved\n"); if (ctx->uc_mcontext.__gregs[REG_EFL] & (1 << 21)) { kos_current_task += 1; if (kos_current_task > kos_task_count) { @@ -33,36 +32,33 @@ void scheduler(int signo, siginfo_t *info, void *context) { } kos_current_slot = kos_slot_base + kos_current_task; kos_task_base = ((taskdata_t*)&kos_current_task) + kos_current_task; - printf("##### kos_current_task: %u\n", kos_current_task); +// printf("##### kos_current_task: %u\n", kos_current_task); setitimer(ITIMER_PROF, &timeout, NULL); siglongjmp(*kos_slot_base[kos_current_task].fpu_state, 1); } } -//void intwrite(int fd, - void monitor() { fprintf(stderr, "Start monitor thread\n"); // mkfifo("/tmp/umka.fifo.2u", 0644); // mkfifo("/tmp/umka.fifo.4u", 0644); FILE *fin = fopen("/tmp/umka.fifo.2u", "r"); FILE *fout = fopen("/tmp/umka.fifo.4u", "w"); -// while (1) { - fprintf(stderr, "### from monitor: %d\n", fileno(fout)); -// } if (!fin || !fout) { fprintf(stderr, "Can't open monitor files!\n"); return; } run_test(fin, fout, 0); +/* while (1) { for (int i = 0; i < 10000000; i++) {} printf("6 monitor\n"); } - +*/ } int main() { + umka_tool = UMKA_OS; struct sigaction sa; sa.sa_sigaction = scheduler; diff --git a/umka_shell.c b/umka_shell.c index 2a0e8bd..391b52e 100644 --- a/umka_shell.c +++ b/umka_shell.c @@ -30,6 +30,7 @@ #include "trace.h" int main(int argc, char **argv) { + umka_tool = UMKA_SHELL; const char *usage = \ "usage: umka_shell [test_file.t] [-c]\n" " -c collect coverage";