Page 1 of 1
[SOLVED!] v86 problem
Posted: Sun Sep 23, 2007 9:47 pm
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
) 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?
Re: v86 problem
Posted: Mon Sep 24, 2007 5:50 am
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?
Posted: Mon Sep 24, 2007 11:26 am
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.
Posted: Wed Sep 26, 2007 4:57 am
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
Posted: Wed Sep 26, 2007 3:45 pm
by jerryleecooper
Looks like I screamed victory too early.
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.
Posted: Wed Sep 26, 2007 6:33 pm
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?
Posted: Wed Sep 26, 2007 8:15 pm
by jerryleecooper
It works, that means my aptiva doesn't has an anti floppy mode switching circuitry! :-%
Solution:
Changing
For
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.
Posted: Thu Sep 27, 2007 9:13 am
by lukem95
and still no code
*hints*
congrats on getting it working though!
Posted: Thu Sep 27, 2007 1:24 pm
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.
You can use floppy emulation to load from your USB if your laptop supports it.
Posted: Sat Sep 29, 2007 9:07 am
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?
Posted: Sat Sep 29, 2007 2:13 pm
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.
Posted: Sat Sep 29, 2007 3:12 pm
by Brynet-Inc
What exactly is a 'fob' Dex? making up words now?
Posted: Sat Sep 29, 2007 3:29 pm
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.