This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
a question about porting to harddisk boot of pc!
- To: ecos-discuss at sources dot redhat dot com
- Subject: [ECOS] a question about porting to harddisk boot of pc!
- From: =?gb2312?q?=BA=C6=C8=BB=20=C7=FC?= <quhrmail at yahoo dot com dot cn>
- Date: Tue, 13 Nov 2001 16:11:51 +0800 (CST)
hi all:
now I want to modify ecos so that application can be
run from hard disk of pc target.So I modify
ecos/package/hal/1386/pcmbcurrent/include/pcmb.inc
main step is followed:
1.instead of reseting floppy I reset hard disk
2.I get reference of hard disk such as sectors of it
head number of it
3.I move the reference to variable
4.call int 13h to read hard disk.
when I had modified source code, i build the binary by
using configuration tools .And then i make a
application demo.c to a.out by using i386-elf-gcc
,and I use the command i386-elf-objcopy to make a.out
hardboot.bin .
then i use the command dd to let hardboot.bin to hard
disk .
then restart my pc target ,i found that the computer
print three line "." just like boot from floppy . But
it didn't run my application ,instead it die.
who can give me a hand to resove this question?
the followed is my modified code!
.......
sectorsPerTrack = 0
bytesPerSector = 512
esPerSector = 32 /* = 512/16 */
headnum = 0
cld /* always count up. */
/* Configure a stack that we can use. */
movl $_start, %eax
movw %ax, %sp
shr $4, %eax
andl $0xF000, %eax
movw %ax, %ss
/* Ask the BIOS for info about the amount of RAM
available. We push
* these onto the stack for later use.
*/
xorl %eax, %eax
movb $0x88, %ah /* Get the amount of extended
memory. */
int $0x15
shl $10, %eax
pushl %eax
xorl %eax, %eax
int $0x12 /* Get the amount of standard memory. */
shl $10, %eax
pushl %eax
/* reset hard disk */
movb $0,%ah
movb $0x80,%dl
int $0x13
jc _error1
/*code about check hard disk wrote by quhr*/
movw $(0x0E*256+'s'), %ax /* hard disk1 start
check*/
int $0x10
movb $0x8,%ah
movb $0x80,%dl
clc
int $0x13
jc _fail
/* test about harddisk reference */
movb %ah,headnum
andb $0x3F,%cl
movb %cl,sectorsPerTrack
/*test is over*/
movl $_start,%eax
movw %ax,%bx
andw $0xF,%bx
shrl $4,%eax
movw %ax, %es
/* initials head/track/sector */
movw $0x80,%dx
movw $0x0101,%cx
movl $_edata,%edi
addl $(bytesPerSector-1),%edi
shrl $4,%edi
jmp _loadsector
_nextsector:
movw %es,%ax
cmpw %di,%ax
jge _endload
addw $esPerSector,%ax
movw %ax,%es
incb %cl /* secter add 1*/
cmpb $sectorsPerTrack, %cl
jbe _loadsector
movb $1, %cl /*sector set 1*/
incb %dh
cmpb $headnum,%dh
jbe _loadsector
movb $0, %dh
incb %ch
_loadsector:
pushw %es
pushw %di
movw $0x0201, %ax
clc
int $0x13
popw %di
popw %es
jc _error2
movw $(0x0E*256+'.'), %ax int $0x10
ljmp $0,$_nextsector
_fail: movw $(0x0E*256+'f'), %ax /* hard disk1 start
fail */
int $0x10
jmp _error
_error1:
.....
_error2:
.....
_error:
.....
. = _start + 510
.byte 0x55
.byte 0xAA
_endload:
......
_________________________________________________________
Do You Yahoo!? 登录免费雅虎电邮! http://mail.yahoo.com.cn
<font color=#6666FF>无聊?郁闷?高兴?没理由?都来聊天吧!</font>——
雅虎全新聊天室! http://cn.chat.yahoo.com/c/roomlist.html