- devfs.vp: string.split 传 PATH_BUFFER_SIZE(配合 split 新增容量参数) - fat32_types.vp: lfn_extract 越界钳制(base+i > MAX_LFN 返回 -1) - sheet.vp: gfx.Renderer 实参修正为 (fb, zb, w, h)(原单参导致 w/h=0 渲染空操作) - 同批包含 VKernel 其余既有移植改动与 vpsdk/Apps/Libs 工作区内容
27 lines
682 B
Plaintext
27 lines
682 B
Plaintext
import asm
|
|
import t, c
|
|
|
|
PIT_CHANNEL0: t.CDefine = 0x40
|
|
PIT_CHANNEL1: t.CDefine = 0x41
|
|
PIT_CHANNEL2: t.CDefine = 0x42
|
|
PIT_COMMAND: t.CDefine = 0x43
|
|
|
|
def pit_init(frequency: int):
|
|
# 参数验证:确保频率为正数
|
|
if frequency <= 0: return
|
|
|
|
# 计算除数,使用16位无符号整数
|
|
divisor: uint32 = 1193180 / frequency
|
|
|
|
# 发送命令字:通道0,先低后高,模式3(方波),二进制计数
|
|
asm.outb(PIT_COMMAND, 0x36)
|
|
asm.io_wait()
|
|
|
|
# 写入低字节
|
|
asm.outb(PIT_CHANNEL0, divisor & 0xFF)
|
|
asm.io_wait()
|
|
|
|
# 写入高字节
|
|
asm.outb(PIT_CHANNEL0, (divisor >> 8) & 0xFF)
|
|
asm.io_wait()
|