2 Star 5 Fork 4

稀风 / KOS

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Build.py 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
稀风 提交于 2022-12-28 19:24 . 内核雏形:优化遗留问题
import os
OUTPUT = "output"
BOOT_SRC = "./bootloader/boot.asm"
BOOT_BIN = "./output/boot.bin"
LOADER_SRC = "./bootloader/loader.asm"
LOADER_BIN = "./output/loader.bin"
IMG = "./output/a.img"
def main():
# os.path.exists(path) # path是文件夹或者文件的相对路径或者绝对路径
# 创建文件夹 output
if not os.path.exists(OUTPUT):
os.mkdir(OUTPUT)
# 编译 boot.asm
src = BOOT_SRC
out = BOOT_BIN
cmd_str = "nasm " + src + " -o " + out
print(cmd_str)
os.system(cmd_str)
# 编译 loader.asm
src = LOADER_SRC
out = LOADER_BIN
cmd_str = "nasm " + src + " -o " + out
print(cmd_str)
os.system(cmd_str)
# 创建一个 60M 的虚拟硬盘,由于搭了两套开发环境,所以这里 bximage 有两种命令格式
# 使用 “bximage --help” 命令可获得 bximage 的用法
# 另一个:bximage $@ -func="create" -hd=60 -imgmode="flat" -q
cmd_str = "bximage " + IMG + ' -hd -size=60 -mode="flat" -q'
print(cmd_str)
os.system(cmd_str)
# 将 boot.bin 写入硬盘 a.img 的第 0 个扇区
cmd_str = "dd if=" + BOOT_BIN + " of=" + IMG + " bs=512 count=1 conv=notrunc"
print(cmd_str)
os.system(cmd_str)
# dd if=$(BOOT_BIN) of=$(IMG) bs=512 count=1 conv=notrunc
# 将 loader.bin 写入硬盘 a.img 的第 2 个扇区开始的连续 20 个扇区(10K)
cmd_str = "dd if=" + LOADER_BIN + " of=" + IMG + " bs=512 count=20 seek=2 conv=notrunc"
print(cmd_str)
os.system(cmd_str)
print("Success!")
if __name__ == '__main__':
main()
1
https://gitee.com/thin-wind/KOS.git
git@gitee.com:thin-wind/KOS.git
thin-wind
KOS
KOS
main

搜索帮助

53164aa7 5694891 3bd8fe86 5694891