/kernel/trunk/runtests.py |
---|
172,7 → 172,7 |
return thread |
def gcc(fin, fout): |
flags = "-m32 -std=c11 -g -O0 -fno-pie -w" # -masm-intel |
flags = "-m32 -std=c11 -g -O0 -fno-pie -w" |
defines = "-D_FILE_OFFSET_BITS=64 -DNDEBUG -D_POSIX_C_SOURCE=200809L" |
include = "-Iumka -Iumka/linux" |
command = f"clang {flags} {defines} {include} -c {fin} -o {fout}" |
185,8 → 185,13 |
files = "umka/umka.asm umka/build/umka.o -s umka/build/umka.fas" |
memory = "-m 2000000" |
command = f"{include} fasm {flags} {files} {memory}" |
if sys.platform != "win32": |
print(command) |
os.system(command) |
else: |
my_env = os.environ.copy() |
my_env["INCLUDE"] = "../../programs/develop/libraries/libcrash/hash" |
print(subprocess.check_output(f"fasm {flags} {files} {memory} -dwin32=1", shell = True, env = my_env)) |
def build_umka(): |
if not enable_umka: |
194,12 → 199,16 |
if os.path.exists("umka_shell.exe"): |
return |
os.makedirs("umka/build/linux", exist_ok = True) |
os.makedirs("umka/build/win32", exist_ok = True) |
sources = [ "umka_shell.c", |
"shell.c", |
"vdisk.c", |
"lodepng.c", |
"linux/pci.c", |
"linux/thread.c" ] |
"getopt.c" ] |
if sys.platform == "win32": |
sources += [ "win32/pci.c", "win32/thread.c" ] |
else: |
sources += [ "linux/pci.c", "linux/thread.c" ] |
sources = [f"umka/{f}" for f in sources] |
objects = [] |
for source in sources: |
210,9 → 219,16 |
build_umka_asm() |
objects.append("umka/build/umka.o") |
objects = " ".join(objects) |
command = f"gcc -m32 -no-pie -o umka_shell.exe -static -T umka/umka.ld {objects}" |
if sys.platform != "win32": |
ld_script = "-T umka/umka.ld" |
else: |
ld_script = "" |
command = f"clang -m32 -fno-pie -o umka_shell.exe -static {ld_script} {objects}" |
print(command) |
os.system(command) |
if not os.path.exists("umka_shell.exe"): |
print("Could't compile umka_shell.exe") |
exit() |
def create_relocated(root_dir, fname): |
with open(fname, "rb") as f: |
227,8 → 243,18 |
def run_umka_test(root_dir, test_file_path): |
test = create_relocated(root_dir, test_file_path) |
ref_log = create_relocated(root_dir, f"{test_file_path[:-2]}.ref.log") |
out_log = f"{test_file_path[:-2]}.out.log.o" |
os.system(f"./umka_shell.exe < {test} > {out_log}") |
out_log = f"{test_file_path[:-2]}.out.log" |
if sys.platform != "win32": |
prefix = "./" |
else: |
prefix = "" |
os.system(f"{prefix}umka_shell.exe < {test} > {out_log}") |
if sys.platform == "win32": |
with open(out_log, "rb") as f: |
contents = f.read() |
contents_no_crlf = contents.replace(b"\r\n", b"\n") |
with open(out_log, "wb") as f: |
f.write(contents_no_crlf) |
if not filecmp.cmp(ref_log, out_log): |
print(f"FAILURE: {test_file_path}\n", end = "") |
else: |
/kernel/trunk/test/common/__init__.py |
---|
89,7 → 89,8 |
def run_qemu(root_dir, test_dir, debug_log): |
# Make local copy of IMG, so we will be able to run the test in parallel |
os.remove(f"{test_dir}/kolibri_test.img") # If previous test run interrupted the file may be busy |
if os.path.exists(f"{test_dir}/kolibri_test.img"): # If previous test run interrupted the file may be busy |
os.remove(f"{test_dir}/kolibri_test.img") |
shutil.copyfile(f"{root_dir}/kolibri_test.img", f"{test_dir}/kolibri_test.img") |
qemu_command = f"qemu-system-i386" |
flags = "" |
/kernel/trunk/umka/shell.c |
---|
307,7 → 307,7 |
return; |
} |
const char *fname = argv[1]; |
FILE *f = fopen(fname, "r"); |
FILE *f = fopen(fname, "rb"); |
if (!f) { |
fprintf(fout, "[!] can't open file '%s': %s\n", fname, strerror(errno)); |
return; |
1093,7 → 1093,7 |
fputs(usage, fout); |
return; |
} |
FILE *f = fopen(argv[1], "r"); |
FILE *f = fopen(argv[1], "rb"); |
fseek(f, 0, SEEK_END); |
size_t fsize = ftell(f); |
rewind(f); |
1126,7 → 1126,7 |
fputs(usage, fout); |
return; |
} |
FILE *f = fopen(argv[1], "r"); |
FILE *f = fopen(argv[1], "rb"); |
fseek(f, 0, SEEK_END); |
size_t fsize = ftell(f); |
rewind(f); |
1332,7 → 1332,7 |
return; |
} |
const char *fname = argv[1]; |
FILE *f = fopen(fname, "r"); |
FILE *f = fopen(fname, "rb"); |
if (!f) { |
fprintf(fout, "[!] can't open file '%s': %s\n", fname, strerror(errno)); |
return; |
1763,7 → 1763,7 |
fputs(usage, fout); |
return; |
} |
FILE *f = fopen(argv[1], "r"); |
FILE *f = fopen(argv[1], "rb"); |
if (!f) { |
fprintf(fout, "[umka] can't open file: %s\n", argv[1]); |
return; |
1781,30 → 1781,6 |
} |
static void |
shell_pci_set_path(int argc, char **argv) { |
const char *usage = \ |
"usage: pci_set_path <path>\n" |
" path where aaaa:bb:cc.d dirs are"; |
if (argc != 2) { |
fputs(usage, fout); |
return; |
} |
strcpy(pci_path, argv[1]); |
} |
static void |
shell_pci_get_path(int argc, char **argv) { |
(void)argv; |
const char *usage = \ |
"usage: pci_get_path"; |
if (argc != 1) { |
fputs(usage, fout); |
return; |
} |
fprintf(fout, "pci path: %s\n", pci_path); |
} |
static void |
shell_bg_set_size(int argc, char **argv) { |
const char *usage = \ |
"usage: bg_set_size <xsize> <ysize>\n" |
1869,7 → 1845,7 |
fputs(usage, fout); |
return; |
} |
FILE *f = fopen(argv[1], "r"); |
FILE *f = fopen(argv[1], "rb"); |
fseek(f, 0, SEEK_END); |
size_t fsize = ftell(f); |
rewind(f); |
1949,8 → 1925,6 |
{ "ls80", shell_ls80 }, |
{ "move_window", shell_move_window }, |
{ "mouse_move", shell_mouse_move }, |
{ "pci_get_path", shell_pci_get_path }, |
{ "pci_set_path", shell_pci_set_path }, |
{ "process_info", shell_process_info }, |
{ "put_image", shell_put_image }, |
{ "put_image_palette", shell_put_image_palette }, |
/kernel/trunk/umka/umka.asm |
---|
1,7 → 1,37 |
; TODO: SPDX |
if ~ defined win32 |
format ELF |
else |
format MS COFF |
macro c_public name, _alias, _argsize { |
if ~ _argsize eq nomangle |
if _alias eqtype 'string' |
if _argsize eqtype 1 |
public name as '_' # _alias # '@' # `_argsize |
else |
public name as '_' # _alias |
end if |
else if _alias eqtype 1 |
public name as '_' # `name # '@' # `_alias |
else |
public name as '_' # `name |
end if |
else |
public name as _alias |
end if |
} |
macro extrn name, _argsize { |
if _argsize eqtype 1 |
extrn '_' # `name # '@' # `_argsize as name |
else |
extrn '_' # `name as name |
end if |
} |
end if |
__DEBUG__ = 1 |
__DEBUG_LEVEL__ = 1 |
11,73 → 41,73 |
UMKA_MEMORY_BYTES = 256 SHL 20 |
public umka_sys_put_image_palette |
public disk_add |
public disk_del |
public disk_list |
public disk_media_changed |
c_public umka_sys_put_image_palette |
c_public disk_add, 16 |
c_public disk_del, 4 |
c_public disk_list |
c_public disk_media_changed,8 |
public xfs._.user_functions as 'xfs_user_functions' |
public ext_user_functions |
public fat_user_functions |
public ntfs_user_functions |
c_public xfs._.user_functions, 'xfs_user_functions' |
c_public ext_user_functions |
c_public fat_user_functions |
c_public ntfs_user_functions |
public i40 |
c_public i40, 'i40', nomangle |
public coverage_begin |
public coverage_end |
c_public coverage_begin |
c_public coverage_end |
public sha3_256_oneshot as 'hash_oneshot' |
public kos_time_to_epoch |
public umka_init |
c_public sha3_256_oneshot, 'hash_oneshot' |
c_public kos_time_to_epoch |
c_public umka_init |
public current_process as 'kos_current_process' |
public current_slot as 'kos_current_slot' |
public current_slot_idx as 'kos_current_slot_idx' |
c_public current_process, 'kos_current_process' |
c_public current_slot, 'kos_current_slot' |
c_public current_slot_idx, 'kos_current_slot_idx' |
public thread_count as 'kos_thread_count' |
public TASK_TABLE as 'kos_task_table' |
public TASK_BASE as 'kos_task_base' |
public TASK_DATA as 'kos_task_data' |
public SLOT_BASE as 'kos_slot_base' |
public window_data as 'kos_window_data' |
c_public thread_count, 'kos_thread_count' |
c_public TASK_TABLE, 'kos_task_table' |
c_public TASK_BASE, 'kos_task_base' |
c_public TASK_DATA, 'kos_task_data' |
c_public SLOT_BASE, 'kos_slot_base' |
c_public window_data, 'kos_window_data' |
public WIN_STACK as 'kos_win_stack' |
public WIN_POS as 'kos_win_pos' |
public lfb_base as 'kos_lfb_base' |
c_public WIN_STACK, 'kos_win_stack' |
c_public WIN_POS, 'kos_win_pos' |
c_public lfb_base, 'kos_lfb_base' |
public RAMDISK as 'kos_ramdisk' |
public ramdisk_init as 'kos_ramdisk_init' |
c_public RAMDISK, 'kos_ramdisk' |
c_public ramdisk_init, 'kos_ramdisk_init' |
public acpi_ssdt_cnt as 'kos_acpi_ssdt_cnt' |
public acpi_ssdt_base as 'kos_acpi_ssdt_base' |
public acpi_ssdt_size as 'kos_acpi_ssdt_size' |
c_public acpi_ssdt_cnt, 'kos_acpi_ssdt_cnt' |
c_public acpi_ssdt_base, 'kos_acpi_ssdt_base' |
c_public acpi_ssdt_size, 'kos_acpi_ssdt_size' |
public stack_init as 'kos_stack_init' |
public net_add_device |
c_public stack_init, 'kos_stack_init' |
c_public net_add_device |
public draw_data |
public img_background |
public mem_BACKGROUND |
public sys_background |
public REDRAW_BACKGROUND as 'kos_redraw_background' |
public new_sys_threads as 'kos_new_sys_threads' |
public osloop as 'kos_osloop' |
public set_mouse_data as 'kos_set_mouse_data' |
public scheduler_current as 'kos_scheduler_current' |
public eth_input as 'kos_eth_input' |
public net_buff_alloc as 'kos_net_buff_alloc' |
c_public draw_data |
c_public img_background |
c_public mem_BACKGROUND |
c_public sys_background |
c_public REDRAW_BACKGROUND, 'kos_redraw_background' |
c_public new_sys_threads, 'kos_new_sys_threads', nomangle |
c_public osloop, 'kos_osloop' |
c_public set_mouse_data, 'kos_set_mouse_data', 20 |
c_public scheduler_current, 'kos_scheduler_current' |
c_public eth_input, 'kos_eth_input' |
c_public net_buff_alloc, 'kos_net_buff_alloc' |
public mem_block_list |
c_public mem_block_list |
public acpi_dev_data as "kos_acpi_dev_data" |
public acpi_dev_size as "kos_acpi_dev_size" |
public kernel_alloc as "kos_kernel_alloc" |
c_public acpi_dev_data, "kos_acpi_dev_data" |
c_public acpi_dev_size, "kos_acpi_dev_size" |
c_public kernel_alloc, "kos_kernel_alloc" |
public window._.set_screen as 'kos_window_set_screen' |
public _display as 'kos_display' |
c_public window._.set_screen, 'kos_window_set_screen' |
c_public _display, 'kos_display' |
public BOOT as 'kos_boot' |
c_public BOOT, 'kos_boot' |
macro cli { |
pushfd |
112,7 → 142,7 |
macro diff16 msg,blah2,blah3 { |
if msg eq "end of .data segment" |
; fasm doesn't align on 65536, but ld script does |
section '.bss.aligned65k' writeable align 65536 |
section '.bss.65k' writeable align 512 |
bss_base: |
end if |
} |
505,7 → 535,7 |
ret |
endp |
public skin_udata |
c_public skin_udata |
proc idle uses ebx esi edi |
.loop: |
mov ecx, 10000000 |
517,7 → 547,7 |
ret |
endp |
extrn pci_read |
extrn pci_read, 20 |
proc pci_read_reg uses ebx esi edi |
mov ecx, eax |
and ecx, 3 |
541,6 → 571,7 |
proc sys_msg_board |
cmp cl, 0x0d |
jz @f |
if ~ defined win32 |
pushad |
mov eax, SYS_WRITE |
mov ebx, STDOUT |
550,6 → 581,15 |
int 0x80 |
pop ecx |
popad |
else |
extrn putchar |
pushad |
push ecx |
call putchar |
add esp, 4 |
popad |
end if |
@@: |
ret |
endp |
559,13 → 599,13 |
ret |
endp |
public umka_cli |
c_public umka_cli |
proc umka_cli |
cli ; macro |
ret |
endp |
public umka_sti |
c_public umka_sti |
proc umka_sti |
sti ; macro |
ret |
593,7 → 633,7 |
extrn reset_procmask |
extrn get_fake_if |
public irq0 |
c_public irq0 |
proc irq0 c, _signo, _info, _context |
DEBUGF 2, "### irq0\n" |
pushfd |
735,10 → 775,10 |
coverage_end: |
; fasm doesn't align on 65536, but ld script does |
section '.data.aligned65k' writeable align 65536 |
public umka_tool |
section '.data' readable writeable align 512 |
c_public umka_tool |
umka_tool dd ? |
public umka_initialized |
c_public umka_initialized |
umka_initialized dd 0 |
fpu_owner dd ? |
/kernel/trunk/umka/umka.h |
---|
9,6 → 9,12 |
#define BDFE_LEN_CP866 304 |
#define BDFE_LEN_UNICODE 560 |
#if defined(WIN32) || defined(_WIN32) |
typedef size_t off_t; |
typedef long ssize_t; |
# define PATH_MAX 256 |
#endif |
typedef struct { |
uint32_t left, top, right, bottom; |
} rect_t; |
/kernel/trunk/umka/vdisk.c |
---|
21,9 → 21,9 |
printf("vdisk: can't open file '%s': %s\n", fname, strerror(errno)); |
return NULL; |
} |
fseeko(f, 0, SEEK_END); |
off_t fsize = ftello(f); |
fseeko(f, 0, SEEK_SET); |
fseek(f, 0, SEEK_END); |
off_t fsize = ftell(f); |
fseek(f, 0, SEEK_SET); |
size_t sect_size = 512; |
if (strstr(fname, "s4096") != NULL || strstr(fname, "s4k") != NULL) { |
sect_size = 4096; |
51,7 → 51,7 |
size_t *numsectors) { |
COVERAGE_OFF(); |
vdisk_t *vdisk = userdata; |
fseeko(vdisk->file, startsector * vdisk->sect_size, SEEK_SET); |
fseek(vdisk->file, startsector * vdisk->sect_size, SEEK_SET); |
fread(buffer, *numsectors * vdisk->sect_size, 1, vdisk->file); |
COVERAGE_ON(); |
return ERROR_SUCCESS; |
62,7 → 62,7 |
size_t *numsectors) { |
COVERAGE_OFF(); |
vdisk_t *vdisk = userdata; |
fseeko(vdisk->file, startsector * vdisk->sect_size, SEEK_SET); |
fseek(vdisk->file, startsector * vdisk->sect_size, SEEK_SET); |
fwrite(buffer, *numsectors * vdisk->sect_size, 1, vdisk->file); |
COVERAGE_ON(); |
return ERROR_SUCCESS; |
/kernel/trunk/umka/win32/pci.c |
---|
0,0 → 1,8 |
#include "pci.h" |
__attribute__((stdcall)) uint32_t pci_read(uint32_t bus, uint32_t dev, |
uint32_t fun, uint32_t offset, |
size_t len) { |
printf("STUB: %s() -> 0", __func__); |
return 0; |
} |
/kernel/trunk/umka/win32/pci.h |
---|
0,0 → 1,8 |
#ifndef PCI_H_INCLUDED |
#define PCI_H_INCLUDED |
#include "umka.h" |
extern char pci_path[PATH_MAX]; |
#endif // PCI_H_INCLUDED |
/kernel/trunk/umka/win32/thread.c |
---|
0,0 → 1,8 |
void reset_procmask(void) { |
printf("STUB: %s()", __func__); |
} |
int get_fake_if(void *ctx) { |
printf("STUB: %s() -> 0", __func__); |
return 0; |
} |