[SOLVED!] v86 problem

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
jerryleecooper
Member
Member
Posts: 233
Joined: Mon Aug 06, 2007 6:32 pm
Location: Canada

[SOLVED!] v86 problem

Post by jerryleecooper »

Hello. I have v86 working. But I have a problem in Bochs, I get #UD exception, and that in the bochsout file,

Code: Select all

LOCK prefix unallowed (op1=0x53, attr=0x0, mod=0x0, nnn=0)
In Virtual PC it seems to work, but I didn't tried it much.
Here's to v86 code I tried:

Code: Select all

[bits 16]
[org 0x8000]

mov ax, 147


mov ax, 128+2
int 10h

gog:

	mov ax, 43
	jmp gog
	
I based my code ( not in this post :D ) from some sources, v86 from alexey frounze, the virtual 86 tutorial from tim robinson, linux kernel 2.6 etc. I don't see where it could be an error in my code, but it must be an error somewhere.
I have a couple of questions. What values must be in the tss? the ss, ds, es segments of the tss?
Last edited by jerryleecooper on Wed Sep 26, 2007 8:14 pm, edited 3 times in total.
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Re: v86 problem

Post by bluecode »

jerryleecooper wrote:Hello. I have v86 working. But I have a problem in Bochs, I get #UD exception, and that in the bochsout file,

Code: Select all

LOCK prefix unallowed (op1=0x53, attr=0x0, mod=0x0, nnn=0)
Clear sign that something that your code somehow gets to a wrong location and starts execution in the nowhere.
I have a couple of questions. What values must be in the tss? the ss, ds, es segments of the tss?
ss, ds, es, fs & gs should be the realmode segment registers. For the other question we need to know whether you are using hardware taskswitching or not?
User avatar
jerryleecooper
Member
Member
Posts: 233
Joined: Mon Aug 06, 2007 6:32 pm
Location: Canada

Post by jerryleecooper »

Im using software task switching, but with a tss for ring0->ring3 protection. I think I have found the problem. the stack in r->esp is not what it's supposed to be. I dumped it on screen and it was the kernel stack, not the v86 process stack.


edit: it works, thank you for your help. The problem was that I used r->esp instead of r->useresp.
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

:) thanks for posting your solution, so many people neglect that.

Is you OS open source? I would love to get my v86 working properly, if so, could you post your code?

~Luke
User avatar
jerryleecooper
Member
Member
Posts: 233
Joined: Mon Aug 06, 2007 6:32 pm
Location: Canada

Post by jerryleecooper »

Looks like I screamed victory too early. :cry:
It doesn't work anymore in Virtual PC it seems.
I don't know why. I changed something in my code and didn't backup the good one :-(
The problem seems to be the tss not being the right size.
The code runs fine in qemu and bochs, where everything works perfectly. But in Virtual PC, after the pushf instruction, I think comes various input output instructions, that's where the screen get black and I don't like that.
User avatar
jerryleecooper
Member
Member
Posts: 233
Joined: Mon Aug 06, 2007 6:32 pm
Location: Canada

Post by jerryleecooper »

It seems the problem is not with my implementation of v86, but with the hell that is graphics support. I tried this :

Code: Select all

[bits 16]
[org 0x8000]

mov	ah, 00h
mov	al, 128+13h

int	10h

mov     ax, 0a000h
mov     es, ax
; Offset 0
xor     di, di
; Colorword red red
mov     ax, 2727h
; Looplength (320*200)/2 = 7d00
mov     cx, 7d00h
; Draw pixels, one word at a time
rep     stosw


gog:

	mov ax, 43
	jmp gog
	
On both bochs qemu, the result was satisfying, displaying pink color, but on a real pc, an old aptiva, the system just started normally, as if no v86 task were executing at all. On virtual pc, the os jams. What can we conclude of that? :?
User avatar
jerryleecooper
Member
Member
Posts: 233
Joined: Mon Aug 06, 2007 6:32 pm
Location: Canada

Post by jerryleecooper »

It works, that means my aptiva doesn't has an anti floppy mode switching circuitry! :-%

Solution:
Changing

Code: Select all

*stack-- = 0x00020202L;
For

Code: Select all

*stack-- = 0x00023202L;
The iopl was wrong!

edit: The problem of my OS not booting with my laptop is solved too. But now I need to write an usb driver because the way I load my v86 tasks is through the floppy disk. :twisted:
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

and still no code :( *hints*


congrats on getting it working though!
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

jerryleecooper wrote: edit: The problem of my OS not booting with my laptop is solved too. But now I need to write an usb driver because the way I load my v86 tasks is through the floppy disk. :twisted:
You can use floppy emulation to load from your USB if your laptop supports it.
User avatar
jerryleecooper
Member
Member
Posts: 233
Joined: Mon Aug 06, 2007 6:32 pm
Location: Canada

Post by jerryleecooper »

I don't know yet if my os will be proprietary or open source. So I cannot release its source code right now. Thank you for your interest. v86 is easy, if your already have multitasking in your kernel, you're near to have v86! Just make sure to have your v86 task in your first mb, so you can access the ivt table, don't bother with paging for now.

I tought about using the bios function to read floppies because it was faster that my floppy driver, but I modified it and is now as fast or faster.
In Virtual PC it's faster, in boch it's more or less as fast. And now I can run v86 tasks without loading them from floppy (I hand code them with the biosinterrupt function) so I can use the bios interrupt for systems without a real floppy drive, like my laptop, but I think that also mean It will support flash keys, no?
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

Int 13h will work with USB fobs under emulation, eg: if your bios can boot from usb key fob and it emulates the fob as a floppy, it will read from the fob if dl = 0 or if it users hdd emulation, if dl=80h.
But emulation only works in real mode. It will end if you move to pmode, it will also return if you go back to real mode.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

What exactly is a 'fob' Dex? making up words now? :wink:
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Post by Tyler »

http://en.wikipedia.org/wiki/Key_fob

I don't see what the form of something has todo with it's technology. I think perhaps he means to specifically refer to Flash Memory Sticks, some of which are Key fobs.

I could of course be way off the mark, not clarifying anything, only suggesting, before anyone get's too defensive.
Post Reply