IMG file

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
david
Member
Member
Posts: 93
Joined: Tue Aug 21, 2007 4:22 am
Location: Beijing.China
Contact:

IMG file

Post by david »

bochs can make hd img file,
in the img file
the first sector is from 0 to 0x1FF, the second sector is from 0x200 to 0x3FF, the third sector is from 0x400 to 0x5FF,
...... etc.
am i right?
Just For Fun
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: IMG file

Post by Troy Martin »

Yep.

post++;
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
david
Member
Member
Posts: 93
Joined: Tue Aug 21, 2007 4:22 am
Location: Beijing.China
Contact:

Re: IMG file

Post by david »

Code: Select all

# hard disk
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=disk, path="c.img", mode=flat, cylinders=20, heads=16, spt=63
the cylinders. heads and spt decide the size of hd img file.
I can creat a file, size is 10,321,920 bytes, named 'c.img', then i can make this file as the hd img file to use.
am i right?
Just For Fun
User avatar
david
Member
Member
Posts: 93
Joined: Tue Aug 21, 2007 4:22 am
Location: Beijing.China
Contact:

Re: IMG file

Post by david »

another question: bochs can not read/write hd via LBA ?

Code: Select all

; LBA
	mov ax, 4200h
	mov dl, 80h
	mov si, offset cs:dap
	push cs
	pop ds
	int 13h

	jmp $

dap:	db	10h
		db	0
		dw	5
		dw	0	
		dw	3000h
		dd	0
		dd	0
when i debug the code, bochs told me that:

Code: Select all

>>PANIC<< int13_harddisk: function 42. Can't use 64bits lba
Just For Fun
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: IMG file

Post by jal »

david wrote:when i debug the code, bochs told me that:

Code: Select all

>>PANIC<< int13_harddisk: function 42. Can't use 64bits lba
Thanks for letting us know. Is there a question?


JAL
captainwiggles
Posts: 23
Joined: Tue Nov 11, 2008 3:03 pm

Re: IMG file

Post by captainwiggles »

bochs works with 28 bit LBA, but not 48 bit, and I didn't even know 64 bit LBA existed :\
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: IMG file

Post by Troy Martin »

captainwiggles wrote:and I didn't even know 64 bit LBA existed :\
Me neither, and I've been at this for almost a year :) You learn new things every day.





Ooohhhhh, so that's why we have school....
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: IMG file

Post by quok »

captainwiggles wrote:bochs works with 28 bit LBA, but not 48 bit, and I didn't even know 64 bit LBA existed :\
Bochs 2.3.7 (perhaps 2.3.5, I'm not sure) works fine with 48-bit LBA. It's in the Changelog for one of the two versions.
JohnnyTheDon
Member
Member
Posts: 524
Joined: Sun Nov 09, 2008 2:55 am
Location: Pennsylvania, USA

Re: IMG file

Post by JohnnyTheDon »

The 64-bit LBA eror is because the upper bits of the LBA address you're sending has something other than 0s in it. Somewhere the LBA address is getting corrupted, either in your DAP or when you generate the address.
User avatar
david
Member
Member
Posts: 93
Joined: Tue Aug 21, 2007 4:22 am
Location: Beijing.China
Contact:

Re: IMG file

Post by david »

I use Bochs 2.3.5
Just For Fun
User avatar
david
Member
Member
Posts: 93
Joined: Tue Aug 21, 2007 4:22 am
Location: Beijing.China
Contact:

Re: IMG file

Post by david »

my error, i forgot the cs's value is 0 when bochs jmps to 0x7c00.

it's ok now.

Code: Select all

; set CS=07C0, IP=@F
	push 07C0h
	push @F
	retf
@@:	

; LBA
	mov ax, 4200h
	mov dl, 80h
	mov si, offset cs:dap
	push cs
	pop ds
	int 13h

dap:	db	10h
		db	0
		dw	5
		dw	0	
		dw	3000h
		dd	0
		dd	0
Just For Fun
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: IMG file

Post by Troy Martin »

Instead of this:

Code: Select all

; set CS=07C0, IP=@F
	push 07C0h
	push @F
	retf
@@:
You should probably do this:

Code: Select all

; set CS = 07C0h, IP = after this jump
	jmp 0x07C0:sync

sync:
Saves a byte IIRC. And in a bootloader, a byte saved is both a byte earned AND a seriously important thing.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
Post Reply