MS VPC Issue

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator:Moderators

Post Reply
xixpsychoxix
Posts:59
Joined:Tue Oct 13, 2009 8:49 pm
MS VPC Issue

Post by xixpsychoxix » Sat Dec 14, 2013 6:18 pm

Ok all, I am using the following code to get the boot sector of my disk within my stage 2 loader:

Code: Select all

;****************************************************************
;	_fat12_Initialize: Initialize the FAT12 device
;	Parameters: DL - device number
;	Returns: AX = 0 on success, 1 on failure
;****************************************************************

_fat12_Initialize:

	; save all registers. Five error retries
	mov di,5
	
	; save the current disk number in _currentDisk
	mov byte [_currentDisk],dl
	
.try_loop:

	xor ax,ax			; BIOS function 0 (reset disk)
	int 0x13			; reset
	
	; since we have invalid data in the table, we need to raw-load sector 0
	
	mov ax,0x0
	mov es,ax
	
	mov bx,_fat12_BPB				; our buffer for the sector
	mov ah,0x02						; bios function 2
	mov al,1						; read one sector
	mov cl,0x01						; read sector 1
	mov ch,0x00						; the cylinder number is zero
	mov dh,0x00						; the head number is zero, and dl already contains the drive number
	mov dl,byte [_currentDisk]		; load the disk number (just in case?)
	
	int 0x13				; call the interrupt
	jnc .loaded				; if we were successful, finish
	
	; setup for retry
	
	dec di					; decrement error counter
	jnz .try_loop			; if we have tries left, try again
	stc						; otherwise, set carry flag and return
	
.loaded:

	; return
	ret
This code is working fine in VMWare and Bochs. A lack of working floppy disks has prevented my testing it on real hardware, but it seems to be working fine in everything but MS Virtual PC 2007. I get an error (AH = 0x01?) when calling this function. Anyone know what may be causing this? I have the system working well, but I can't seem to pinpoint what may be happening in VPC.

xixpsychoxix
Posts:59
Joined:Tue Oct 13, 2009 8:49 pm

Re: MS VPC Issue

Post by xixpsychoxix » Sat Dec 21, 2013 9:15 pm

Update: So I got THIS function to work in VPC by moving the disk reset call below the sector load call, but now for some reason I cannot load the file. The function call to my file loader never returns. I am at work now but will try to post source code for the loader when I get home. BTW, is forum participation down? Seems like low response numbers lately :D

halofreak1990
Posts:92
Joined:Thu May 27, 2010 8:54 pm
Location:Netherlands

Re: MS VPC Issue

Post by halofreak1990 » Sun Dec 22, 2013 6:36 pm

I guess everyone's kind of waiting for mike to put up the next chapter and doesn't want to 'pollute' the forums with random discussions.

pathos
Moderator
Posts:97
Joined:Thu Jan 10, 2008 6:43 pm
Location:USA

Re: MS VPC Issue

Post by pathos » Fri Dec 27, 2013 2:16 pm

xixpsychoxix wrote:BTW, is forum participation down? Seems like low response numbers lately :D
I check in every day, but I'm terrible at this stuff so I didn't try to help you =/

This forum was never really hopping, but has certainly been extra quiet for a few months now. Not sure why Mike is either. It's too bad. This is the best OS Dev tutorial out there.

User avatar
Mike
Site Admin
Posts:465
Joined:Sat Oct 20, 2007 7:58 pm
Contact:

Re: MS VPC Issue

Post by Mike » Wed Jan 08, 2014 10:57 pm

Hello,

Apologies for the late response.

Be careful with preserving the registers as the BIOS makes no guarantees. Make sure to push/pop DI in order to preserve the counter. Additionally, add additional error checking: make sure that the disk gets reset without error. Note that the disk reset BIOS service takes AH=0, DL=Drive number. The value of DL in the provided function is never set during reset.

We recommend staying with the original posted code (with the above modifications of course.) The disk reset should be done prior to reading from the disk not after.

albus
Posts:9
Joined:Wed May 30, 2012 2:14 pm

Re: MS VPC Issue

Post by albus » Thu Jan 30, 2014 4:38 pm

Mike you'll continue the tutorial on the OS development?

User avatar
Mike
Site Admin
Posts:465
Joined:Sat Oct 20, 2007 7:58 pm
Contact:

Re: MS VPC Issue

Post by Mike » Sun Mar 02, 2014 11:08 pm

Hello,

Yes, the series is still continuing. A couple of chapters are being worked on; particularly Graphics 3 and Process Management 2. Unfortunately due to a lack of time, we have not been able to push out these articles yet. In the worst case, they will be out a little later this year.

If interested, topics for Process Management 2 include but may not be limited to scheduling, multi-threading, introduction to MP systems, init and idle process, shared resources, mutual exclusion, concurrent programming, security, and kernel shared data.

We will try to push it out some time in the next two weeks if possible. Apologies for the long delay -- they are almost complete though. :)

halofreak1990
Posts:92
Joined:Thu May 27, 2010 8:54 pm
Location:Netherlands

Re: MS VPC Issue

Post by halofreak1990 » Tue Mar 04, 2014 9:49 pm

include but may not be limited to scheduling, multi-threading, introduction to MP systems, init and idle process, shared resources, mutual exclusion, concurrent programming, security, and kernel shared data.
Sounds good, mike. Nice to hear you're still working on this great series.

astrocrep
Posts:3
Joined:Fri Jun 04, 2010 4:42 am

Re: MS VPC Issue

Post by astrocrep » Fri Apr 11, 2014 3:10 pm

Mike wrote:Hello,

Yes, the series is still continuing. A couple of chapters are being worked on; particularly Graphics 3 and Process Management 2. Unfortunately due to a lack of time, we have not been able to push out these articles yet. In the worst case, they will be out a little later this year.

If interested, topics for Process Management 2 include but may not be limited to scheduling, multi-threading, introduction to MP systems, init and idle process, shared resources, mutual exclusion, concurrent programming, security, and kernel shared data.

We will try to push it out some time in the next two weeks if possible. Apologies for the long delay -- they are almost complete though. :)
Your tutorials rock, thanks for them! Any chances for a sneak peak at the upcoming materials?? Need any testing?

Thanks,
Rich

Post Reply