阅读:1466回复:8
有没有谁对bios编过程序?
model tiny
.386 code segment assume cs:code,ds:code start: signature db 55H,0AAH comlength db 01H jmp near ptr begin0 ;the length of this instruction is 3 reserved db 20 dup(?) begin0: call getip mov ax,0 mov es,ax mov ax,es:[64H] mov saveip,ax mov ax,es:[66H] mov savecs,ax mov ax,offset begin1 add ax,ipstart mov es:[64H],ax mov es:[66H],cs ;hook the 19H interrupt mov ax,0 mov si,510 again:add ax,cs:[si] dec si jns again neg al mov checksum,al ;compute checksum mov ax,0 retf begin1: sti pusha push es push ds mov ax,cs mov ds,ax mov ax,0 mov es,ax mov ax,saveip mov es:[64H],ax mov ax,savecs mov es:[66H],ax ;restore the original interrupt mov di,25 mov ah,2 mov bh,0 mov dx,di mov dh,10 int 10H ;mov the cursom to the point(10,25)of the screen mov si,offset string ;start to print the string,and wait for the F1 key pressed add si,ipstart showstr: mov ah,9 mov al,[si] and al,0FFH jz kbinput mov bh,0 mov bl,0DAH mov cx,1 int 10H inc si inc di mov ah,2 mov bh,0 mov dx,di mov dh,10 int 10H jmp showstr kbinput: mov ah,0 int 16H cmp ah,3bH jne kbinput pop ds pop es popa int 19H iret getip proc pop ax push ax sub ax,29 mov ipstart,ax ret getip endp string db 'Hello!Press F1 to continue...',00H saveip dw ? savecs dw ? ipstart dw ? org 511 checksum db 59H code ends 写了这个程序以后,我: masm embed.asm link embed exe2bin embed.exe embed.bin cbrom bios.bin /isa embed.bin awdflash bios.bin /SN /PY 重启,在第二屏画面中间打印:hello!Press F1 to continue。。。。 然后死机。怎么会这样呢? 像这种isa rom pci rom 规范到底用什么关键词去搜索呢,总是找不到。 我刚刚接触bios,希望大家指点。 |
|
|
沙发#
发布于:2004-06-23 16:30
我写过bios也看不懂啊,大概说说你要干啥
55AA你也没有check过啊 |
|
板凳#
发布于:2004-06-23 19:50
看不出程序有什么问题。
既然屏幕已经显示出打印信息了,按了F1键应该就可以引导OS了呀 实在不行你就用直接跳转代替int19试试看 另外在链接的时候可以直接加/tiny参数,就省得再用exe2bin了 |
|
地板#
发布于:2004-06-24 13:30
谢谢楼上的二位,我这段程序的目的是对系统bios 19H中断做一个钩子,先打印一段话,再调用原来的中断。我看了看 pnp bios specification,bios的初始化顺序为:
Step 1 Disable all configurable devices Step 2 Identify all Plug and Play ISA devices Step 3 Construct an initial resource map of allocated resources Step 4 Enable Input and Output Devices Step 5 Perform ISA ROM scan Step 6 Configure the IPL device Step 7 Enable Plug and Play ISA and other Configurable Devices Step 8 Initiate the Interrupt 19H IPL sequence Step 9 Operating system takes over resource management 这就可能导致一个问题,就是执行我写的这个isa rom的时候,那个时候的系统还没有形成一个有效的19H中断向量。所以导致了死机。 还有就是signature应该是没有问题的。 |
|
|
地下室#
发布于:2004-06-24 17:09
pop ds
pop es popa int 19H iret 我感觉这里有问题 晕倒,int 19不就是reboot system么? |
|
5楼#
发布于:2004-06-24 19:35
既然产生了打印信息,int19肯定是hook成功的。
我用我的调试卡帮你跟了跟,发现确实是由于系统int19向量没有被正确还原造成的。应该在你主程序开头加上 mov ax,cs mov ds,ax 就没问题了。 附件是我重新编译的bin文件,你可以试试。 |
|
|
6楼#
发布于:2004-06-27 00:09
请教一下,如果我想做一个BIOS ROM代码,让它在扫描IDE磁盘之前就加载,这样可能吗?
jerry_yang,在你的加载顺序中,那一步是bios检测ide硬盘呀? 我想bios在检测ide硬盘之前,先向 ide硬盘发送特别的初始化用的ide command. 这样有可能吗? |
|
|
7楼#
发布于:2004-06-28 13:33
从理论的角度来说,是不可能的,但是isa rom的执行在配置可启动设备之前,所以你应该可以在配置之前做点什么。
你试试下面这个程序,我试过,好像是执行硬盘检测之后。 code segment assume cs:code,ds:code start: signature db 55h,0aah comlength db 01h jmp near ptr begin0 reserved db 20 dup(?) begin0: pushf push ds push es mov di,25 mov ah,2 mov bh,0 mov dx,di mov dh,10 int 10h mov si,offset string showstr: mov ah,9 mov al,[si] and al,0ffh jz kbinput mov bh,0 mov bl,0DAh mov cx,1 int 10h inc si mov ah,2 mov bh,0 inc di mov dx,di mov dh,10 int 10h jmp showstr kbinput: mov ah,0 int 16h cmp ah,3bh jne kbinput pop ds pop es popf retf string db 'Hello! Press F1 to continue...',00h org 511 checksum db 1CH code ends end start 你的bios要是award bios哦。 |
|
|
8楼#
发布于:2004-06-30 16:23
bios的高手们:
请教大家一个问题,好像bios有电源管理设置,其中是否有 硬盘停转的设置,不知代码中是怎样实现的,是不是向硬盘发送ATA命令阿!多谢! |
|