提交新的建议忽略
This commit is contained in:
1 parent
be92f671d0
commit
8b40203b63
8 files changed
+28
-16
No files matched your search
+6
-1
@@ -90,4 +90,9 @@ Undo/vmware/
|
||||
.trae/
|
||||
|
||||
# 编译链
|
||||
_UNCADK/
|
||||
_UNCADK/
|
||||
|
||||
# 编译
|
||||
**/output/
|
||||
**/temp/
|
||||
**/.tpv_build/
|
||||
@@ -1,8 +1,8 @@
|
||||
import asm
|
||||
import t, c
|
||||
import serial
|
||||
import drivers.usb.pci as pci
|
||||
import drivers.serial.uart.serial as serial
|
||||
import viperlib
|
||||
import pci
|
||||
|
||||
|
||||
class IDError(t.CEnum):
|
||||
@@ -54,6 +54,7 @@ def waitDataReady(baseport: t.CUInt16T) -> t.CStatic | IDError:
|
||||
return IDError.IDE_ERR_TIMEOUT
|
||||
|
||||
def init() -> t.CInt:
|
||||
global _ide_initialized
|
||||
if _ide_initialized: return IDError.IDE_ERR_NONE
|
||||
dbg: t.CArray[t.CChar, 120]
|
||||
bus: t.CUInt8T
|
||||
|
||||
@@ -242,7 +242,7 @@ def reset(io_base: t.CUInt16T) -> t.CInt:
|
||||
return 0
|
||||
|
||||
def init(io_base: t.CUInt16T) -> t.CInt:
|
||||
global _io_base, _frame_list, _ctrl_qh, _bulk_qh, _int_slot_count
|
||||
global _irq, _io_base, _frame_list, _ctrl_qh, _bulk_qh, _int_slot_count
|
||||
_io_base = io_base
|
||||
_int_slot_count = 0
|
||||
|
||||
|
||||
@@ -26,9 +26,8 @@ class UIComponent:
|
||||
value: t.CInt
|
||||
|
||||
def __init__(self, ctype: t.CInt, sh: sheet.Sheet | t.CPtr, x: t.CInt, y: t.CInt, w: t.CInt, h: t.CInt):
|
||||
global _next_component_id
|
||||
self.id = _next_component_id
|
||||
_next_component_id += 1
|
||||
self.id = sheet._next_component_id
|
||||
sheet._next_component_id += 1
|
||||
self.ctype = ctype
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
@@ -7,6 +7,9 @@ import paging.paging as paging
|
||||
import sched.process as proc
|
||||
import sched.sched as sched
|
||||
import intr.gdt as gdt
|
||||
import t, c
|
||||
|
||||
|
||||
# Do NOT import KERN_STACK_SIZE/USER_STACK_SIZE from process - CDefine cross-module import is broken
|
||||
# Redefine them here to ensure correct values
|
||||
KERN_STACK_SIZE: t.CDefine = 8192
|
||||
@@ -438,7 +441,7 @@ def spawn_elf(path: t.CConst | str) -> t.CInt:
|
||||
if p.pid >= 0 and p.pid < MAX_SPAWNED:
|
||||
_elf_entries[p.pid] = entry
|
||||
|
||||
th: sched.Thread | t.CPtr = sched.Scheduler.create_thread(_elf_entry_wrapper, t.CVoid(t.CUInt64T(p.pid), t.CPtr), p.pid)
|
||||
th: sched.Thread | t.CPtr = sched.Scheduler.create_thread(t.CPtr(_elf_entry_wrapper), t.CPtr(t.CUInt64T(p.pid)), p.pid)
|
||||
if th is None:
|
||||
serial.puts("[elf] spawn: create_thread failed\n")
|
||||
p.exit()
|
||||
@@ -464,7 +467,7 @@ def _resolve_symbol(name: t.CConst | t.CChar | t.CPtr) -> t.CVoid | t.CPtr:
|
||||
ch2: t.CChar = c.Deref(name + si2)
|
||||
if ch2 == 46:
|
||||
if sha1_len2 >= 8:
|
||||
cmp_name = t.CConst(t.CUInt64T(name) + si2 + 1, t.CPtr)
|
||||
cmp_name = str(t.CUInt64T(name) + si2 + 1)
|
||||
cmp_len = nm - si2 - 1
|
||||
break
|
||||
if ch2 == 0:
|
||||
@@ -677,6 +680,8 @@ def load_so(path: t.CConst | str) -> t.CVoid | t.CPtr:
|
||||
|
||||
fat32.close(fp)
|
||||
|
||||
global _so_strtab, _so_symtab, _so_syment, _so_sym_count
|
||||
|
||||
_so_strtab = strtab_ptr
|
||||
_so_symtab = symtab_ptr
|
||||
_so_syment = syment
|
||||
|
||||
@@ -642,6 +642,7 @@ def compact_memory() -> t.CStatic | t.CInt:
|
||||
|
||||
# 虚拟内存分配函数
|
||||
def vm_alloc(size: t.CUInt64T, flags: t.CUInt32T) -> t.CUInt64T:
|
||||
global vm_areas
|
||||
# 4K对齐
|
||||
size = align_4k(size)
|
||||
|
||||
@@ -699,6 +700,7 @@ def vm_alloc(size: t.CUInt64T, flags: t.CUInt32T) -> t.CUInt64T:
|
||||
|
||||
# 虚拟内存释放函数
|
||||
def vm_free(VirtAddr: t.CUInt64T):
|
||||
global vm_areas
|
||||
# 查找虚拟内存区域
|
||||
current: vm_area | t.CPtr = vm_areas
|
||||
prev: vm_area | t.CPtr = None
|
||||
|
||||
@@ -46,7 +46,7 @@ def init_pool(buf: t.CVoid | t.CPtr, buf_size: t.CUInt64T):
|
||||
pt_pool_used = 0
|
||||
|
||||
def AllocPage() -> t.CVoid | t.CPtr:
|
||||
global pt_pool_used, pml4, pdp, pd, pt
|
||||
global AllocatedPages, pt_pool_used, pml4, pdp, pd, pt
|
||||
if pt_pool_raw is None: return None
|
||||
if pt_pool_used >= t.CUInt64T(PT_POOL_PAGES): return None
|
||||
page: t.CVoid | t.CPtr = t.CVoid(pt_pool_start + pt_pool_used * t.CUInt64T(4096), t.CPtr)
|
||||
@@ -60,9 +60,9 @@ def AllocPage() -> t.CVoid | t.CPtr:
|
||||
return page
|
||||
|
||||
def FreePage(page: t.CVoid | t.CPtr):
|
||||
global pml4, pdp, pd, pt
|
||||
global AllocatedPages, pml4, pdp, pd, pt
|
||||
if page is None: return
|
||||
if AllocatedPages > t.CUInt64T(0): AllocatedPages = AllocatedPages - t.CUInt64T(1)
|
||||
if AllocatedPages > 0: AllocatedPages = AllocatedPages - t.CUInt64T(1)
|
||||
|
||||
def MapPage(VirtAddr: t.CUInt64T, PhysAddr: t.CUInt64T, flags: t.CUInt64T):
|
||||
global pml4, pdp, pd, pt
|
||||
@@ -183,7 +183,7 @@ def GetCurrentPml4() -> _p | t.CPtr:
|
||||
global pml4, pdp, pd, pt
|
||||
cr3: t.CUInt64T
|
||||
c.Asm(f"mov {c.AsmOut(cr3, t.ASM_DESCR.OUTPUT_REG)}, cr3")
|
||||
return t.CType(cr3 & ~t.CUInt64T(0xFFF), _p, t.CPtr)
|
||||
return (_p | t.CPtr)(cr3 & ~t.CUInt64T(0xFFF))
|
||||
|
||||
def create_process_page_table() -> t.CUInt64T:
|
||||
global pml4
|
||||
@@ -293,4 +293,4 @@ def restore_pt_range(save_buf: t.CUInt64T | t.CPtr, save_count: t.CUInt32T):
|
||||
|
||||
def set_active_pml4(cr3_val: t.CUInt64T):
|
||||
global pml4
|
||||
pml4 = t.CType(cr3_val & ~t.CUInt64T(0xFFF), _p, t.CPtr)
|
||||
pml4 = (_p | t.CPtr)(cr3_val & ~t.CUInt64T(0xFFF))
|
||||
@@ -1817,7 +1817,7 @@ def desktop_thread(arg: t.CVoid | t.CPtr) -> t.CInt:
|
||||
_fps_val = t.CUInt32T(t.CUInt64T(_perf_frames) * 1000 / _elapsed_ms)
|
||||
string.memset(c.Addr(_perf_buf), 0, 256)
|
||||
viperlib.snprintf(c.Addr(_perf_buf), 256, "[perf] fps=%u wall=%lu work=%lu mouse=%lu kbd=%lu render=%lu(bg=%lu win=%lu cur=%lu fb=%lu) dirty=%d vsync=%d\n", _fps_val, t.CUInt64T(_elapsed_ms), t.CUInt64T(_perf_t_total), t.CUInt64T(_perf_t_mouse), t.CUInt64T(_perf_t_kbd), t.CUInt64T(_perf_t_render), t.CUInt64T(_perf_t_bg), t.CUInt64T(_perf_t_win), t.CUInt64T(_perf_t_cur), t.CUInt64T(_perf_t_fb), _dirty_count, _vblank_ok)
|
||||
serial.puts(c.Addr(_perf_buf))
|
||||
serial.puts(_perf_buf)
|
||||
_perf_t_mouse = 0
|
||||
_perf_t_kbd = 0
|
||||
_perf_t_render = 0
|
||||
@@ -1834,7 +1834,7 @@ def desktop_thread(arg: t.CVoid | t.CPtr) -> t.CInt:
|
||||
|
||||
def start(fb_ptr: t.CVoid | t.CPtr, w: t.CInt, h: t.CInt, pitch: t.CInt = 0) -> sched.Thread | t.CPtr:
|
||||
global _fb, _screen_w, _screen_h, _fb_pitch, _cursor_x, _cursor_y
|
||||
global _back_fb, _row_buf
|
||||
global _bg_row_buf, _back_fb, _row_buf
|
||||
global _dirty_rows, _prev_cursor_x, _prev_cursor_y
|
||||
_fb = fb_ptr
|
||||
_screen_w = w
|
||||
|
||||
Reference in new issue
Block a user