diff --git a/Libs/VPUI64/linker.ld b/Libs/VPUI64/linker.ld deleted file mode 100644 index bd3258d..0000000 --- a/Libs/VPUI64/linker.ld +++ /dev/null @@ -1,34 +0,0 @@ -SECTIONS { - . = 0; - - .text : { - *(.text) - *(.text.*) - } - - .rodata : { - *(.rodata) - *(.rodata.*) - } - - .data : { - *(.data) - *(.data.*) - } - - .bss : { - PROVIDE(__bss_start = .); - *(.bss) - *(.bss.*) - PROVIDE(__bss_end = .); - } - - /DISCARD/ : { - *(.comment) - *(.note) - *(.eh_frame) - *(.eh_frame_hdr) - *(.reloc) - *(.debug*) - } -} diff --git a/Libs/VPUI64/project.vpj b/Libs/VPUI64/project.vpj deleted file mode 100644 index 0065c35..0000000 --- a/Libs/VPUI64/project.vpj +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "VPUI64", - "version": "1.0.0", - "source_dir": "./", - "build_dir": "./__vpcbuild__", - "compiler": { - "cmd": "llc", - "flags": ["-filetype=obj", "-mtriple=x86_64-none-elf", "-relocation-model=pic", "-O2"] - }, - "linker": { - "cmd": "ld.lld.exe", - "flags": [ - "-m", "elf_x86_64", - "-T", "linker.ld", - "--oformat", "elf64-x86-64", - "-shared", - "-z", "notext", - "--no-relax", - "--strip-all" - ], - "output": "vpui64.so" - }, - "includes": ["../..", "../../../../includes"], - "target": { - "triple": "x86_64-none-elf", - "datalayout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - }, - "options": { - "slice_level": 3, - "target": "llvm", - "strict_mode": true - } -} diff --git a/Libs/VPUI64/vpui64.vp b/Libs/VPUI64/vpui64.vp deleted file mode 100644 index bc79045..0000000 --- a/Libs/VPUI64/vpui64.vp +++ /dev/null @@ -1,80 +0,0 @@ -import t -import vpsdk.syscall as syscall - -UINT32PTR: t.CTypedef = uint32* - -def color_rgb(r: uint8, g: uint8, b: uint8) -> uint32: - return uint32(r) | (uint32(g) << 8) | (uint32(b) << 16) - -def get_winbuf(win_id: int) -> UINT32PTR: - return syscall._syscall2(uint64(syscall.Syscall.GET_WINBUF), uint64(win_id), 0) - -def win_flush(win_id: int): - syscall._syscall2(uint64(syscall.Syscall.WIN_FLUSH), uint64(win_id), 0) - -export def draw_pixel(buf: UINT32PTR, bw: int, x: int, y: int, color: uint32): - if x < 0 or y < 0: return - buf[y * bw + x] = color - -export def draw_line(buf: UINT32PTR, bw: int, x0: int, y0: int, x1: int, y1: int, color: uint32): - dx: int = x1 - x0 - dy: int = y1 - y0 - sx: int = 1 - sy: int = 1 - if dx < 0: - dx = -dx - sx = -1 - if dy < 0: - dy = -dy - sy = -1 - err: int = dx - dy - while True: - if x0 >= 0 and y0 >= 0: - buf[y0 * bw + x0] = color - if x0 == x1 and y0 == y1: - break - e2: int = 2 * err - if e2 > -dy: - err -= dy - x0 += sx - if e2 < dx: - err += dx - y0 += sy - -export def draw_rect(buf: UINT32PTR, bw: int, rx: int, ry: int, rw: int, rh: int, color: uint32): - draw_line(buf, bw, rx, ry, rx + rw - 1, ry, color) - draw_line(buf, bw, rx + rw - 1, ry, rx + rw - 1, ry + rh - 1, color) - draw_line(buf, bw, rx + rw - 1, ry + rh - 1, rx, ry + rh - 1, color) - draw_line(buf, bw, rx, ry + rh - 1, rx, ry, color) - -export def fill_rect(buf: UINT32PTR, bw: int, rx: int, ry: int, rw: int, rh: int, color: uint32): - if rx < 0: rw += rx; rx = 0 - if ry < 0: rh += ry; ry = 0 - if rw <= 0 or rh <= 0: return - py: int = ry - while py < ry + rh: - px: int = rx - while px < rx + rw: - buf[py * bw + px] = color - px += 1 - py += 1 - -export def draw_circle(buf: UINT32PTR, bw: int, cx: int, cy: int, r: int, color: uint32): - x: int = r - y: int = 0 - d: int = 1 - r - while x >= y: - if cx + x >= 0: buf[(cy + y) * bw + cx + x] = color - if cx + y >= 0: buf[(cy + x) * bw + cx + y] = color - if cx - y >= 0: buf[(cy + x) * bw + cx - y] = color - if cx - x >= 0: buf[(cy + y) * bw + cx - x] = color - if cx - x >= 0: buf[(cy - y) * bw + cx - x] = color - if cx - y >= 0: buf[(cy - x) * bw + cx - y] = color - if cx + y >= 0: buf[(cy - x) * bw + cx + y] = color - if cx + x >= 0: buf[(cy - y) * bw + cx + x] = color - y += 1 - if d <= 0: - d += 2 * y + 1 - else: - x -= 1 - d += 2 * (y - x) + 1 diff --git a/README.md b/README.md index 081cf49..ab15cd5 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ A bare-metal 64-bit operating system written in the [Viper](https://git.gvsds.co - **UEFI 引导器** —— `boot/boot.c`(GNU-EFI 编译为 `disk/EFI/BOOT/bootx64.efi`) - **FAT32 驱动** —— 自研实现,支持挂载、目录、文件操作 - **4 个用户应用** —— HelloWorld / Terminal / Gargantua / Scene3D -- **2 个动态库** —— SerialLogger / VPUI64 +- **1 个动态库** —— SerialLogger - **ViperPOS SDK** —— 用户态开发库(系统调用、窗口、文件系统、进程) ### 目录结构 @@ -62,8 +62,7 @@ ViperOS/ │ ├── Gargantua/ │ └── Scene3D/ ├── Libs/ # 动态库(每个子目录一个 .so) -│ ├── SerialLogger/ -│ └── VPUI64/ +│ └── SerialLogger/ ├── vpsdk/ # ViperPOS SDK(应用开发用) │ ├── __init__.py │ ├── stdlib.py @@ -121,7 +120,7 @@ python build.py `build.py` 会自动完成: 1. 调用 `Projectrans.py` 编译 VKernel → `VKernel/output/kernel.bin` -2. 编译 2 个动态库(SerialLogger、VPUI64) +2. 编译 1 个动态库(SerialLogger) 3. 编译 4 个应用(HelloWorld、Terminal、Gargantua、Scene3D) 4. 拷贝所有产物到 `disk/apps/`、`disk/libs/`、`disk/sys/kernel/x86_64/` 5. 调用 `Scripts/disk.ps1` 创建 64MB FAT32 镜像 `disk.img` @@ -187,7 +186,7 @@ Main components: - **UEFI bootloader** — `boot/boot.c` (compiled by GNU-EFI to `disk/EFI/BOOT/bootx64.efi`) - **FAT32 driver** — self-implemented, supports mount/dir/file operations - **4 user applications** — HelloWorld / Terminal / Gargantua / Scene3D -- **2 dynamic libraries** — SerialLogger / VPUI64 +- **1 dynamic library** — SerialLogger - **ViperPOS SDK** — user-space development kit (syscall, window, fs, process) ### Directory layout @@ -228,8 +227,7 @@ ViperOS/ │ ├── Gargantua/ │ └── Scene3D/ ├── Libs/ # shared libraries (each subdir = one .so) -│ ├── SerialLogger/ -│ └── VPUI64/ +│ └── SerialLogger/ ├── vpsdk/ # ViperPOS SDK (for user apps) │ ├── __init__.py │ ├── stdlib.py @@ -287,7 +285,7 @@ python build.py `build.py` automatically: 1. Calls `Projectrans.py` to build VKernel -> `VKernel/output/kernel.bin` -2. Builds 2 shared libraries (SerialLogger, VPUI64) +2. Builds 1 shared library (SerialLogger) 3. Builds 4 applications (HelloWorld, Terminal, Gargantua, Scene3D) 4. Copies all artifacts into `disk/apps/`, `disk/libs/`, `disk/sys/kernel/x86_64/` 5. Calls `Scripts/disk.ps1` to create a 64MB FAT32 image `disk.img` diff --git a/build.py b/build.py index 5ae65a5..506e0c5 100644 --- a/build.py +++ b/build.py @@ -18,6 +18,8 @@ only_app = '--onlyapp' in sys.argv build_kernel = '--kernel' in sys.argv or kernel_only # --libs:编译 Libs/ 下的动态库(不带 --app 时默认也会编) libs = '--libs' in sys.argv +# --nokernel:强制跳过内核编译(显式 --kernel 优先,仍可强制编内核) +nokernel = '--nokernel' in sys.argv # --app=a,b,c:只编译列出的应用(逗号分隔、可多个)。不传则编译全部应用。 app_filter = None for _arg in sys.argv: @@ -27,11 +29,19 @@ for _arg in sys.argv: # 默认(不带 --app)重编内核;--app=… 视为只迭代应用。 if app_filter is None: build_kernel = True +# --nokernel 强制跳过内核编译,但显式 --kernel 仍优先(允许用 --kernel 覆盖 --nokernel)。 +if nokernel and '--kernel' not in sys.argv: + build_kernel = False + +# --kernel-only 与 --nokernel 互斥检查 +if kernel_only and nokernel: + print("[build] 错误: --kernel-only 与 --nokernel 互斥") + sys.exit(1) def BuildKernel(): """编译内核:链接器一次产出带符号 kernel.elf,再由 objcopy 二次处理成裸镜像 kernel.bin""" - cmd = r'..\..\ViperC\output\viperc.exe --project ./VKernel/project.vpj --clear-cache --rebuild-includes' + cmd = r'..\..\ViperC\__vpcbuild__\output\viperc.exe --project ./VKernel/project.vpj --clear-cache --rebuild-includes' if clean: cmd += ' --clean' os.system(cmd) @@ -61,7 +71,6 @@ APP_LIST = [ # 动态库表:(工程目录, 产物文件名) LIB_LIST = [ ("Libs/SerialLogger", "slog.so"), - ("Libs/VPUI64", "vpui64.so"), ] @@ -69,7 +78,7 @@ def BuildLibs(): """编译 Libs/ 下的动态库(应用运行期经 LOAD_SO 加载)。""" os.makedirs("./disk/libs", exist_ok=True) for proj, out in LIB_LIST: - cmd = rf'..\..\ViperC\output\viperc.exe --project {proj}/project.vpj --clear-cache' + cmd = rf'..\..\ViperC\__vpcbuild__\output\viperc.exe --project {proj}/project.vpj --clear-cache' if clean: cmd += ' --clean' os.system(cmd) @@ -114,7 +123,7 @@ def BuildApps(): for name, proj, out, dst in APP_LIST: if app_filter is not None and name not in app_filter: continue - cmd = rf'..\..\ViperC\output\viperc.exe --project {proj}/project.vpj --clear-cache' + cmd = rf'..\..\ViperC\__vpcbuild__\output\viperc.exe --project {proj}/project.vpj --clear-cache' if clean: cmd += ' --clean' os.system(cmd) @@ -215,9 +224,9 @@ else: if build_kernel: BuildKernel() else: - print("[build] 默认不重编内核(需要时加 --kernel)") + print("[build] 跳过内核编译(--app 或 --nokernel)") BuildApps() BuildBootloader() BuildDisk() -RunQemu() +RunQemu() \ No newline at end of file