[ECOS] a question about porting to harddisk boot of pc!

浩然 屈 quhrmail@yahoo.com.cn
Fri Nov 2 08:17:00 GMT 2001


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



More information about the Ecos-discuss mailing list