Page 1 of 1
Bochs error
Posted: Wed Apr 14, 2010 11:21 pm
by Ehsanulhaq
hi,
I am trying to read 9 sectors from FD using the following code with bochs
Code: Select all
mov $0x02,%ah
mov $0x09,%al #no of sectors
mov $0x00,%ch #
mov $0x02,%cl #sector #
mov $0x01,%dh #head
mov $0x0100,%bx
mov %bx,%es
mov $0x0000,%bx
int $0x13
I am getting the following errors.
Code: Select all
00012943037i[BIOS ] Booting from 0000:7c00
00012943875i[FDD ] read() on floppy image returns 0
00012988830i[FDD ] read() on floppy image returns 0
00013033785i[FDD ] read() on floppy image returns 0
00013078740i[FDD ] read() on floppy image returns 0
00013123695i[FDD ] read() on floppy image returns 0
00013168650i[FDD ] read() on floppy image returns 0
00013213605i[FDD ] read() on floppy image returns 0
00013258560i[FDD ] read() on floppy image returns 0
00013303515i[FDD ] read() on floppy image returns 0
could anyone plz help??
Thanks,
Re: Bochs error
Posted: Thu Apr 15, 2010 1:57 am
by TylerH
It looks like you're getting a successful read, but there's nothing for Bochs to read. How big is you image your using to boot from? If you don't have anything after the boot sig, try putting something there, and see if one of those "read() on floppy image returns 0" turns into "read() on floppy image returns [however much you added]".
Re: Bochs error
Posted: Thu Apr 15, 2010 2:37 am
by Ehsanulhaq
Thanks for your reply.Could you plz tell how can i write some to an image file after first 512 byte using dd
command or any other tools.The size of the image file is 5kb and i am giving this image file as input to floppy drive of bochs.
Thanks,
Re: Bochs error
Posted: Thu Apr 15, 2010 3:53 am
by Combuster
how can i write some to an image file after first 512 byte using dd
using "conv=..." "seek=..." and
RTFM
Re: Bochs error
Posted: Thu Apr 15, 2010 4:05 am
by jal
Ehsanulhaq wrote:how can i write some to an image file after first 512 byte using dd
man dd. Next time do your homework.
EDIT: Beaten by Combuster.
JAL
Re: Bochs error
Posted: Thu Apr 15, 2010 6:13 pm
by TylerH
You don't have to go through the trouble of using some external utility, just define a really long variable after the boot signature. Possibly a string, then use int 10h, 0eh to print the string from the read buffer to test if the read was successful.
But if your image is >512b then you should at least get a partial read. I don't see where you set dl = drive number, the drive number is passed by Bochs in dl(so you don't necessarily have to set it, but if you modify dl before the read, save it to memory somewhere first. Also, check CF, it's set on an error. Another thing, heads start at 0.
Here's a good resource, it has the possible values for the input regs. You may want to look into getting Helppc(and a DOS emulator), it's good for helping with simple things like this.
Re: Bochs error
Posted: Thu Apr 15, 2010 11:37 pm
by Ehsanulhaq
The following log is generated by bochs when I try to load kernel from the boot device.could any one plz help?
Code: Select all
00000000000i[ ] Bochs x86 Emulator 2.4.2.cvs
00000000000i[ ] Build from CVS snapshot, after release 2.4.2
00000000000i[ ] System configuration
00000000000i[ ] processors: 1 (cores=1, HT threads=1)
00000000000i[ ] A20 line support: yes
00000000000i[ ] CPU configuration
00000000000i[ ] level: 5
00000000000i[ ] SMP support: no
00000000000i[ ] APIC support: yes
00000000000i[ ] FPU support: yes
00000000000i[ ] MMX support: yes
00000000000i[ ] SSE support: no
00000000000i[ ] CLFLUSH support: no
00000000000i[ ] 3dnow! support: no
00000000000i[ ] x86-64 support: no
00000000000i[ ] SEP support: no
00000000000i[ ] MWAIT support: no
00000000000i[ ] XSAVE support: no
00000000000i[ ] AES support: no
00000000000i[ ] VMX support: no
00000000000i[ ] Optimization configuration
00000000000i[ ] RepeatSpeedups support: no
00000000000i[ ] Trace cache support: no
00000000000i[ ] Fast function calls: no
00000000000i[ ] Devices configuration
00000000000i[ ] ACPI support: no
00000000000i[ ] NE2000 support: no
00000000000i[ ] PCI support: no, enabled=yes
00000000000i[ ] SB16 support: no
00000000000i[ ] USB support: no
00000000000i[ ] VGA extension support: vbe
00000000000i[MEM0 ] allocated memory at 0xb587b008. after alignment, vector=0xb587c000
00000000000i[MEM0 ] 32.00MB
00000000000i[MEM0 ] mem block size = 0x00100000, blocks=32
00000000000i[MEM0 ] rom at 0xe0000/131072 ('/usr/local/share/bochs/BIOS-bochs-latest')
00000000000i[MEM0 ] rom at 0xc0000/40448 ('/usr/local/share/bochs/VGABIOS-lgpl-latest')
00000000000e[DEV ] Bochs is not compiled with PCI support
00000000000i[CMOS ] Using local time for initial clock
00000000000i[CMOS ] Setting initial clock to: Thu Apr 15 22:15:14 2010 (time0=1271351714)
00000000000i[DMA ] channel 4 used by cascade
00000000000i[DMA ] channel 2 used by Floppy Drive
00000000000i[FDD ] fd0: 'image' ro=0, h=2,t=80,spt=18
00000000000i[VGA ] interval=150000
00000000000i[MEM0 ] Register memory access handlers: 0x000a0000 - 0x000bffff
00000000000i[MEM0 ] Register memory access handlers: 0xe0000000 - 0xe0ffffff
00000000000i[VGA ] VBE Bochs Display Extension Enabled
00000000000i[ ] init_dev of 'unmapped' plugin device by virtual method
00000000000i[ ] init_dev of 'biosdev' plugin device by virtual method
00000000000i[ ] init_dev of 'speaker' plugin device by virtual method
00000000000i[SPEAK] Open /dev/console successfully
00000000000i[ ] init_dev of 'extfpuirq' plugin device by virtual method
00000000000i[ ] init_dev of 'ioapic' plugin device by virtual method
00000000000i[IOAP ] initializing I/O APIC
00000000000i[MEM0 ] Register memory access handlers: 0xfec00000 - 0xfec00fff
00000000000i[ ] init_dev of 'keyboard' plugin device by virtual method
00000000000i[KBD ] will paste characters every 1000 keyboard ticks
00000000000i[ ] init_dev of 'harddrv' plugin device by virtual method
00000000000i[HD ] Using boot sequence floppy, none, none
00000000000i[HD ] Floppy boot signature check is enabled
00000000000i[ ] init_dev of 'serial' plugin device by virtual method
00000000000i[SER ] com1 at 0x03f8 irq 4
00000000000i[ ] init_dev of 'parallel' plugin device by virtual method
00000000000i[PAR ] parallel port 1 at 0x0378 irq 7
00000000000i[ ] register state of 'unmapped' plugin device by virtual method
00000000000i[ ] register state of 'biosdev' plugin device by virtual method
00000000000i[ ] register state of 'speaker' plugin device by virtual method
00000000000i[ ] register state of 'extfpuirq' plugin device by virtual method
00000000000i[ ] register state of 'ioapic' plugin device by virtual method
00000000000i[ ] register state of 'keyboard' plugin device by virtual method
00000000000i[ ] register state of 'harddrv' plugin device by virtual method
00000000000i[ ] register state of 'serial' plugin device by virtual method
00000000000i[ ] register state of 'parallel' plugin device by virtual method
00000000000i[SYS ] bx_pc_system_c::Reset(HARDWARE) called
00000000000i[CPU0 ] cpu hardware reset
00000000000i[APIC0] allocate APIC id=0 (MMIO enabled) to 0xfee00000
00000000000i[ ] reset of 'unmapped' plugin device by virtual method
00000000000i[ ] reset of 'biosdev' plugin device by virtual method
00000000000i[ ] reset of 'speaker' plugin device by virtual method
00000000000i[ ] reset of 'extfpuirq' plugin device by virtual method
00000000000i[ ] reset of 'ioapic' plugin device by virtual method
00000000000i[ ] reset of 'keyboard' plugin device by virtual method
00000000000i[ ] reset of 'harddrv' plugin device by virtual method
00000000000i[ ] reset of 'serial' plugin device by virtual method
00000000000i[ ] reset of 'parallel' plugin device by virtual method
00000000000i[ ] set SIGINT handler to bx_debug_ctrlc_handler
00000003305i[BIOS ] $Revision: 1.246 $ $Date: 2010/02/08 20:56:55 $
00000318042i[KBD ] reset-disable command received
00000444800i[VBIOS] VGABios $Id: vgabios.c,v 1.69 2009/04/07 18:18:20 vruppert Exp $
00000444871i[VGA ] VBE known Display Interface b0c0
00000444903i[VGA ] VBE known Display Interface b0c5
00000447828i[VBIOS] VBE Bios $Id: vbe.c,v 1.62 2009/01/25 15:46:25 vruppert Exp $
00000760517i[BIOS ] Starting rombios32
00000761014i[BIOS ] Shutdown flag 0
00000761695i[BIOS ] ram_size=0x02000000
00000762173i[BIOS ] ram_end=32MB
00000802507i[BIOS ] Found 1 cpu(s)
00000821776i[BIOS ] bios_table_addr: 0x000fbc18 end=0x000fcc00
00000837139i[BIOS ] MP table addr=0x000fbcf0 MPC table addr=0x000fbc20 size=0xd0
00000839100i[BIOS ] SMBIOS table addr=0x000fbd00
00000839983i[BIOS ] bios_table_cur_addr: 0x000fbe16
00012943037i[BIOS ] Booting from 0000:7c00
00012943875i[FDD ] read() on floppy image returns 0
00012988830i[FDD ] read() on floppy image returns 0
00013033785i[FDD ] read() on floppy image returns 0
00013078740i[FDD ] read() on floppy image returns 0
00013123695i[FDD ] read() on floppy image returns 0
00013168650i[FDD ] read() on floppy image returns 0
00013213605i[FDD ] read() on floppy image returns 0
00013258560i[FDD ] read() on floppy image returns 0
00013303515i[FDD ] read() on floppy image returns 0
00013348470i[FDD ] read() on floppy image returns 0
00013393425i[FDD ] read() on floppy image returns 0
00013438380i[FDD ] read() on floppy image returns 0
00013483335i[FDD ] read() on floppy image returns 0
00013528290i[FDD ] read() on floppy image returns 0
00013573245i[FDD ] read() on floppy image returns 0
00013618200i[FDD ] read() on floppy image returns 0
00013663595i[CPU0 ] LOCK prefix unallowed (op1=0x53, attr=0x0, mod=0x0, nnn=0)
00020164155i[ ] Ctrl-C detected in signal handler.
00020164156i[ ] dbg: Quit
00020164156i[CPU0 ] CPU is in real mode (active)
00020164156i[CPU0 ] CS.d_b = 16 bit
00020164156i[CPU0 ] SS.d_b = 16 bit
00020164156i[CPU0 ] | EAX=00000010 EBX=00009000 ECX=00000002 EDX=00000100
00020164156i[CPU0 ] | ESP=0000fff6 EBP=00000000 ESI=000e32d8 EDI=0000ffac
00020164156i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df if tf sf zf af pf cf
00020164156i[CPU0 ] | SEG selector base limit G D
00020164156i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00020164156i[CPU0 ] | CS:f000( 0004| 0| 0) 000f0000 0000ffff 0 0
00020164156i[CPU0 ] | DS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00020164156i[CPU0 ] | SS:9000( 0005| 0| 0) 00090000 0000ffff 0 0
00020164156i[CPU0 ] | ES:0100( 0005| 0| 0) 00001000 0000ffff 0 0
00020164156i[CPU0 ] | FS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00020164156i[CPU0 ] | GS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00020164156i[CPU0 ] | EIP=0000ff53 (00000003)
00020164156i[CPU0 ] | CR0=0x60000010 CR2=0x00000000
00020164156i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00020164156i[CMOS ] Last time is 1271351719 (Thu Apr 15 22:15:19 2010)
00020164156i[NGUI ] bx_nogui_gui_c::exit() not implemented yet.
00020164156i[CTRL ] quit_sim called with exit code 0
Re: Bochs error
Posted: Fri Apr 16, 2010 8:42 am
by quok
I doubt anyone really could help. You're not providing nearly enough context. Have you tried following the advice already given to you in this thread? We really don't know...
You should take a look at
this essay and really understand it before posting back. Perhaps then you'll be better prepared to help us help you.
Re: Bochs error
Posted: Fri Apr 16, 2010 5:38 pm
by TylerH
Some code would be nice.
Re: Bochs error
Posted: Tue Apr 20, 2010 12:31 pm
by KotuxGuy
Don't think we're mean here or anything, but just remember, these are
real people, and they have to live life, go to their jobs, and go home and recline on the sofa
. So try to ask questions the right way, because these nice people(that being
us, and including
me ) are taking time out of their busy schedules to come help you.
Do you really think they are going to respond nicely if you give a vague question, have to squeeze information out of you, and have to spoonfeed you solutions?
So please, be considerate!
Re: Bochs error
Posted: Tue Aug 24, 2010 2:48 am
by ttessier
KotuxGuy
You know it's a funny thing that you are saying that you are busy and don't have time to answer, but you have the time to spend lecturing about how to post properly. Isn't it also easy to just provide enough information to prompt the correct questions? People who are using your forums and your tutorials are coming here to potentially try your code and service and are sometimes getting frustrated with incomplete or inaccurate or not up to date data and are not always in the right state of mind to ask the appropriate questions.
All communication has to start with a prompt - if it is ok from a console or I have a question from a forum, and turning people off or turning people away is not a good way to promote your forum or site.
Having said that and probably hit a nerve on your end, I am having the same issue, and would like to say that I used a tutorial example on this site and and receiving the following:
00070749873i[BIOS ] Booting from 0000:7c00
00071532363i[FDD ] partial read() on floppy image returns 280/512
00071643984i[FDD ] read() on floppy image returns 0
00071755605i[FDD ] read() on floppy image returns 0
00071867226i[FDD ] read() on floppy image returns 0
00071978847i[FDD ] read() on floppy image returns 0
00072090468i[FDD ] read() on floppy image returns 0
My on disk image file is kernel.img from the tutorials on idt and gdt - it is 4.27 kb
At first glance it appears that the boot code is being loaded and then I am potentially endless looping with 0 bytes returned
Someone mentioned something about setting bochs to use a specific floppy device or association, does anyone know how to do this? I will post my bochrc
# You many now use double quotes around pathnames, in case
# your pathname includes spaces.
romimage: file=bios/BIOS-bochs-latest
vgaromimage: file=bios/VGABIOS-elpin-2.40
megs: 32
floppya: 1_44=KERNEL.IMG, status=inserted
boot: a
log: bochsout.txt
panic: action=ask
error: action=report
info: action=report
debug: action=ignore
vga_update_interval: 300000
keyboard_serial_delay: 250
keyboard_paste_delay: 100000
# floppy_command_delay: 500
cpu: count=1, ips=10000000
mouse: enabled=0
private_colormap: enabled=0
fullscreen: enabled=0
screenmode: name="sample"
keyboard_mapping: enabled=0, map=
#keyboard_type: at
Re: Bochs error
Posted: Tue Aug 24, 2010 7:30 am
by bewing
Please give us the exact size (in bytes) of the image file, and have your code print the floppy CHS values (or AX, CX, DX values) just before the INT 0x13. These will almost certainly show that you are trying to read off the end of your image file. The question is why are you doing such a thing? What do you expect to find there?
Re: Bochs error
Posted: Tue Aug 24, 2010 10:33 am
by Combuster
My on disk image file is kernel.img from the tutorials on idt and gdt - it is 4.27 kb
Well, since CPU-related code doesn't normally help in solving floppy-related problems, please show us how you create the entire floppy image.
then I am potentially endless looping with 0 bytes returned
Is it an endless loop or is it not an endless loop. What does it do exactly in that loop? Being vague about details doesn't work.
Re: Bochs error
Posted: Wed Aug 25, 2010 2:27 pm
by ttessier
building the kernel
gcc -fno-builtins -c *.c
ld -T kernel.ld -o kernel.bin k_init.o kernel.o stdio.o io.o pic.o idt.o panic.o inter.o
copy /b boot+kernel.bin kernel.img > nul
floppy read code - there are more like this - the potentially endless loop is via the jc read - there are many of these statements in the code to load things. I have not looped them, I am
read:
xor ax,ax ; Floppy Reset BIOS Function
mov dl,[drive] ; Select floppy that was booted from
int 0x13
jc read
mov ax,0xffff
mov es,ax ; Data buffer for file
mov bx,0x10 ; Start of segment
mov ah,2 ; Function to read disk
mov al,17 ; Total sectors to read
mov ch,0 ; Track
mov cl,2 ; Sector
mov dh,0 ; Head | Drive is already loaded
int 0x13 ; Call BIOS read disk function
jc read
I have since realized that this is not the same site I was using the original tutorials from so I am probably not going to post or read anything else here.
In regards to being vague, instead of posting 10 miles of code puke, I am attempting to minimize the garbage and prompt where I think the problem is. When I get a request for more information I will provide it - this is how communication normally works.
The reads that I am doing with the floppy is not my own code, I am using bios calls and am asking this community if they have had similar issues.
Re: Bochs error
Posted: Wed Aug 25, 2010 3:41 pm
by Combuster
Two things, the bootloader blatantly dumps a part of the floppy into memory, much more than what the kernel's size actually is. While this doesn't cause problems with Bochs, several other tools are known to have issues with images that are not 1.4M in size.
Anyway, the problem is more likely in how the kernel is stored in memory and started. If your tutorial doesn't have any specific code to locate main() or force it at some fixed location (the order you put things on the command line does not work), its broken and you are probably better off using another one (preferrably one from the wiki). And that doesn't seem to be your tutorial's only problem based on this short description...