diff --git a/shell.c b/shell.c index d9b0d90..e55d040 100644 --- a/shell.c +++ b/shell.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "vdisk.h" #include "vnet.h" #include "umka.h" @@ -288,6 +289,36 @@ void shell_disk_list_partitions(disk_t *d) { } } +void shell_ramdisk_init(int argc, char **argv) { + const char *usage = \ + "usage: ramdisk_init \n" + " absolute or relative path"; + if (argc != 2) { + puts(usage); + return; + } + const char *fname = argv[1]; + FILE *f = fopen(fname, "r"); + if (!f) { + fprintf(fout, "[!] can't open file '%s': %s\n", fname, strerror(errno)); + return; + } + fseek(f, 0, SEEK_END); + size_t fsize = ftell(f); + if (fsize > 2880*512) { + fprintf(fout, "[!] file '%s' is too big, max size is 1474560 bytes\n", + fname); + return; + } + rewind(f); + fread(kos_ramdisk, fsize, 1, f); + fclose(f); + COVERAGE_ON(); + void *ramdisk = kos_ramdisk_init(); + COVERAGE_OFF(); + shell_disk_list_partitions(ramdisk); +} + void shell_disk_add(int argc, char **argv) { const char *usage = \ "usage: disk_add [option]...\n" @@ -1133,7 +1164,9 @@ void shell_acpi_call(int argc, char **argv) { } const char *method = argv[1]; fprintf(fout, "calling acpi method: '%s'\n", method); + COVERAGE_ON(); kos_acpi_call_name(acpi_ctx, method); + COVERAGE_OFF(); fprintf(fout, "acpi method returned\n"); } @@ -1866,6 +1899,7 @@ typedef struct { func_table_t funcs[] = { { "i40", shell_i40 }, + { "ramdisk_init", shell_ramdisk_init }, { "disk_add", shell_disk_add }, { "disk_del", shell_disk_del }, { "ls70", shell_ls70 }, diff --git a/test/016_#f01_#draw_all.ref.log b/test/016_#f01_#draw_all.ref.log index 025149b..08fac13 100644 --- a/test/016_#f01_#draw_all.ref.log +++ b/test/016_#f01_#draw_all.ref.log @@ -1,4 +1,5 @@ -/> disk_add ../img/kolibri.img rd -c 0 +#disk_add ../img/kolibri.img rd -c 0 +/> ramdisk_init ../img/kolibri.img /rd/1: fat /> set_skin /sys/DEFAULT.SKN status: 0 diff --git a/test/016_#f01_#draw_all.t b/test/016_#f01_#draw_all.t index 908d9e1..5657678 100644 --- a/test/016_#f01_#draw_all.t +++ b/test/016_#f01_#draw_all.t @@ -1,4 +1,5 @@ -disk_add ../img/kolibri.img rd -c 0 +#disk_add ../img/kolibri.img rd -c 0 +ramdisk_init ../img/kolibri.img set_skin /sys/DEFAULT.SKN window_redraw 1 draw_window 10 300 5 200 0x000088 1 1 1 0 1 4 hello diff --git a/umka.asm b/umka.asm index 2415989..c73ccb8 100644 --- a/umka.asm +++ b/umka.asm @@ -43,6 +43,7 @@ public WIN_POS as 'kos_win_pos' public lfb_base as 'kos_lfb_base' public RAMDISK as 'kos_ramdisk' +public ramdisk_init as 'kos_ramdisk_init' public enable_acpi public acpi.call_name diff --git a/umka.h b/umka.h index 6b449f5..5dba18f 100644 --- a/umka.h +++ b/umka.h @@ -325,7 +325,7 @@ void kos_init(void); void i40(void); uint32_t kos_time_to_epoch(uint32_t *time); -void *disk_add(diskfunc_t *disk, const char *name, void *userdata, uint32_t flags) __attribute__((__stdcall__)); +disk_t *disk_add(diskfunc_t *disk, const char *name, void *userdata, uint32_t flags) __attribute__((__stdcall__)); void *disk_media_changed(diskfunc_t *disk, int inserted) __attribute__((__stdcall__)); void disk_del(disk_t *disk) __attribute__((__stdcall__)); @@ -337,6 +337,7 @@ extern uint8_t fat_user_functions[]; extern uint8_t ntfs_user_functions[]; extern uint8_t kos_ramdisk[2880*512]; +disk_t *kos_ramdisk_init(void); static inline void kos_enable_acpi() { __asm__ __inline__ __volatile__ (