v86 help

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.
Tom

Re:v86 help

Post by Tom »

i'm not sure if it even sets v86 mode because I press ctrl-alt-delete and nothing happends
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:v86 help

Post by Pype.Clicker »

Tom wrote: i'm not sure if it even sets v86 mode because I press ctrl-alt-delete and nothing happends
hum hum ... trying to do a soft reboot from v86 mode ... this is a strange idea ;-) however, if pressing "Num Lock" toggles the Num Lock LED, then you're in vmode (with IRQs handled in vmode too). Otherwise, you can try to call vint 09 on receipt of IRQ1 (IRQs are usually dispatched to protected mode handlers when in virtual mode ...
forgottologin

Re:v86 help

Post by forgottologin »

dosn't work.

here is my code. look at start16

LOWMIN equ 0 ; minimum low memory needed to run (in K)
EXTMIN equ 0 ; minimum extended memory needed to run (in
TSTAK equ 400h ; total stack size (in bytes)
ISTAK equ 80h ; hardware IRQ safe stack size (in bytes)

[ABSOLUTE 0]
lml resw 1
bsl resw 1
bsm resb 1
acc resb 1
lmh resb 1
bsh resb 1
descr_len

[ABSOLUTE 0]
back resd 1
esp0 resd 1
sp0 resd 1 ; should be 10h
esp1 resd 1
sp1 resd 1
esp2 resd 1
sp2 resd 1
ocr3 resd 1
oeip resd 1
oeflags resd 1
oeax resd 1
oecx resd 1
oedx resd 1
oebx resd 1
oesp resd 1
oebp resd 1
oesi resd 1
oedi resd 1
oes resd 1
ocs resd 1
oss resd 1
ods resd 1
ofs resd 1
ogs resd 1
oldtr resd 1
iomap resd 1 ; should be 104 shl 16
task_len

[segment .text]
[BITS 16]
jmp start16
;???????????????????????????????????????????????????????????????????????????
; 16 bit basic system data
;???????????????????????????????????????????????????????????????????????????
stak16 times 100h db 0
stak16e
oldint1b dd 0 ; ?
old_cs dw 0 ; ?
nullint db 0cfh ; I think it is iret
errmsg0 db 'You must have a 386 or better to run this program!',7,'$'
errmsg1 db 'This system is already in V86 mode!!!',7,'$'
errmsg2 db 'You must have 640k low memory to run this program!',7,'$'
errmsg3 db 'Not enough extended memory to run this program!!!','$'
errmsg4 db 'You must have VGA to run this program!!!',7,'$'
errmsg5 db 'Not enough low memory to run this program!!!',7,'$'
defidt dw 3ffh, 0,0


;???????????????????????????????????????????????????????????????????????????
init_vm86_task
mov dword [ds:v86task+sp0],10h
mov eax,104
shl eax,16
mov [ds:v86task+iomap],eax
ret
forgottologin

Re:v86 help

Post by forgottologin »

;???????????????????????????????????????????????????????????????????????????
start16: ; Program begins here
cli
mov sp,stak16e
mov ax,cs
mov ds,ax
; call chek_VGA
; call chek_processor
; call chek_virtual

mov ax,cs ; Calc misc memory pointers (was code16)
mov [cs:old_cs],ax
movzx eax,ax
shl eax,4
mov [ds:_code16a],eax
mov ax,cs ; was code32
movzx eax,ax
shl eax,4
mov [ds:_code32a],eax
mov ebx,codeend
shl ebx,4
sub ebx,eax
add [ds:v86task+esp0],ebx
add ebx,TSTAK
mov [ds:_lomembase],ebx
mov ebx,100000h
sub ebx,eax
mov [ds:_himembase],ebx
; call chek_memory

xor ax,ax ; Disable CTRL+BREAK
mov es,ax
mov eax,[es:1bh*4]
mov [oldint1b],eax
mov word [es:1bh*4],nullint
mov word [es:1bh*4+2],cs

mov eax,[ds:_code32a] ; Set up protected mode adresses
add dword [ds:gdt32a+2],eax
add dword [ds:idt32a+2],eax
mov [ds:code32dsc+bsl],ax
mov [ds:data32dsc+bsl],ax
add [ds:v86taskdsc+bsl],ax
shr eax,8
mov [ds:code32dsc+bsm],ah
mov [ds:data32dsc+bsm],ah
add [ds:v86taskdsc+bsm],ah
mov eax,[ds:_code16a]
mov [ds:retrealc+bsl],ax
mov [ds:retreald+bsl],ax
shr eax,8
mov [ds:retrealc+bsm],ah
mov [ds:retreald+bsm],ah
call init_vm86_task

   lgdt [ds:gdt32a] ; Init protected mode
mov eax, cr0
or eax, 1
mov cr0, eax

lidt [cs:idt32a]
mov ax,10h
mov ds,ax
mov es,ax
mov fs,ax
mov ss,ax
mov ax,18h
mov gs,ax
mov esp,[_lomembase]
mov ax,20h
ltr ax
pushfd
pop eax
or ah,30h
and ah,10111111b
push eax
popfd
; in al,21h
mov [oirqm21],al
or al,3
; out 21h,al
in al,0a1h
mov [oirqma1],al
mov bx,2820h
call set8529vektorz
call enableA20
sti ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


   mov byte [v86r_ah], 0
   mov byte [v86r_al], 0
mov byte [v86r_ax],13h ; test setting 13h mode
mov al,10h
int 30h

jmp $

;???????????????????????????????????????????????????????????????????????????
v86sys: ; V86 interrupt
xor eax,eax
xor ebx,ebx
xor ecx,ecx
xor edx,edx
xor esi,esi
xor edi,edi
xor ebp,ebp
mov ax,[cs:v86r_ax]
mov bx,[cs:v86r_bx]
mov cx,[cs:v86r_cx]
mov dx,[cs:v86r_dx]
mov si,[cs:v86r_si]
mov di,[cs:v86r_di]
mov bp,[cs:v86r_bp]
db 0cdh
v86sysintnum db 0
mov [cs:v86r_ax],ax
mov [cs:v86r_bx],bx
mov [cs:v86r_cx],cx
mov [cs:v86r_dx],dx
mov [cs:v86r_si],si
mov [cs:v86r_di],di
mov [cs:v86r_bp],bp
mov [cs:v86r_ds],ds
mov [cs:v86r_es],es
pushf
pop ax
mov [cs:v86r_flags],ax
int 0fdh

;???????????????????????????????????????????????????????????????????????????
prerealmode: ; 16 bit protected mode to real mode
lidt [defidt]
mov ax,[old_cs]
mov [new_seg],ax
mov eax,cr0
and al,0feh
mov cr0,eax

db 0eah
dw realmode
new_seg dw 0
realmode: ; Back in real mode
xor ax,ax ; Reenable CTRL+BREAK
mov es,ax
mov eax,[cs:oldint1b]
mov [es:1bh*4],eax
mov ax,cs ; Fix up regs and quit to DOS
mov ds,ax
mov es,ax
mov ss,ax
xor eax,eax
mov fs,ax
mov gs,ax
xor ebx,ebx
xor ecx,ecx
xor edx,edx
xor esi,esi
xor edi,edi
xor ebp,ebp
mov esp,stak16e+200h
mov ax,4c00h
int 21h

dw 0,0,0

;=============================================================================
;------- org 0
forgottologin

Re:v86 help

Post by forgottologin »

[BITS 32]

;???????????????????????????????????????????????????????????????????????????
; 32 bit basic system data
;???????????????????????????????????????????????????????????????????????????
v86task times task_len db 0 ; ?
times 2000h db 0
gdt32 db 0x00,0x00, 0x00,0x00, 0x00, 00000000b, 00000000b, 0
code32dsc db 0xff,0xff, 0x00,0x00, 0x00, 10011010b, 11001111b, 0
data32dsc db 0xff,0xff, 0x00,0x00, 0x00, 10010010b, 11001111b, 0
zerodsc db 0xff,0xff, 0x00,0x00, 0x00, 10010010b, 11001111b, 0
v86taskdsc db 0xff,0xff
dw v86task
db 0x00, 10001001b, 0, 0
retrealc db 0xff,0xff, 0x00,0x00, 0x00, 10011010b, 0, 0
retreald db 0xff,0xff, 0x00,0x00, 0x00, 10010010b, 0, 0
idt32 dw exc0, 8, 08e00h, 0
dw exc1, 8, 08e00h, 0
dw exc2, 8, 08e00h, 0
dw exc3, 8, 08e00h, 0
dw exc4, 8, 08e00h, 0
dw exc5, 8, 08e00h, 0
dw exc6, 8, 08e00h, 0
dw exc7, 8, 08e00h, 0
dw exc8, 8, 08e00h, 0
dw exc9, 8, 08e00h, 0
dw exca, 8, 08e00h, 0
dw excb, 8, 08e00h, 0
dw excc, 8, 08e00h, 0
dw v86gen, 8, 08e00h, 0
dw exce, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw unexp, 8, 08e00h, 0
dw irq0, 8, 08e00h, 0
dw irq1, 8, 08e00h, 0
dw irq2, 8, 08e00h, 0
dw irq3, 8, 08e00h, 0
dw irq4, 8, 08e00h, 0
dw irq5, 8, 08e00h, 0
dw irq6, 8, 08e00h, 0
dw irq7, 8, 08e00h, 0
dw irq8, 8, 08e00h, 0
dw irq9, 8, 08e00h, 0
dw irqa, 8, 08e00h, 0
dw irqb, 8, 08e00h, 0
dw irqc, 8, 08e00h, 0
dw irqd, 8, 08e00h, 0
dw irqe, 8, 08e00h, 0
dw irqf, 8, 08e00h, 0
dw callv86sys, 8, 8e00h, 0
gdt32a dw 037h, gdt32,0
idt32a dw 187h, idt32,0

v86irqnum db 0 ; num of IRQ that ocurred in V86 mod
v86r_ax ; Virtual regs for virtual ints
v86r_al db 0
v86r_ah db 0
v86r_bx
v86r_bl db 0
v86r_bh db 0
v86r_cx
v86r_cl db 0
v86r_ch db 0
v86r_dx
v86r_dl db 0
v86r_dh db 0
v86r_si dw 0
v86r_di dw 0
v86r_bp dw 0
v86r_ds dw 0
v86r_es dw 0
v86r_flags dw 0

oirqm21 db 0 ; old low IRQ mask
oirqma1 db 0 ; old high IRQ mask
_totalextmem dw 0 ; total extended memory present
_code16a dd 0 ; offset of start of program from 0
_code32a dd 0 ; offset of start of 32bit code from
_lomembase dd 0 ; low mem base for allocation
_lomemtop dd 0 ; top of low mem
_himembase dd 0 ; high mem base for allocation
_himemtop dd 0 ; top of high mem
_hextbl db '0123456789ABCDEF'
forgottologin

Re:v86 help

Post by forgottologin »

;???????????????????????????????????????????????????????????????????????????
; 32 bit basic system code
;???????????????????????????????????????????????????????????????????????????
;???????????????????????????????????????????????????????????????????????????
callv86sys: ; V86 INT AL
pushad
push es
push fs
push gs
mov bx,18h
mov es,bx
mov ebx,[_code16a]
mov [es:v86sysintnum+ebx],al
push dword [v86task+esp0]
mov ecx,esp
sub esp,ISTAK
mov [v86task+esp0],esp
xor eax,eax
push eax
push eax
mov ax,[v86r_ds]
push eax
mov ax,[v86r_es]
push eax
mov eax,codeend
push eax
shl eax,4
sub eax,[_code32a]
sub ecx,eax
push ecx
pushfd
pop eax
or eax,20000h
push eax
mov ax, word [cs:old_cs] ; ????????????????????????????????????
movzx eax,ax
push eax
mov eax,v86sys
push eax
iretd
retfromv86:
mov ax,10h
mov ds,ax
mov esp,[v86task+esp0]
add esp,ISTAK
pop dword [v86task+esp0]
pop gs
pop fs
pop es
popad
iretd
;???????????????????????????????????????????????????????????????????????????
v86gen: ; General protection violation handl
test byte [esp+14],2
jnz short v86genv86
pushad
mov dl,13
jmp exc

v86genv86:
add esp,4
pushad
mov ax,18h
mov ds,ax
movzx ebx,word [esp+36]
shl ebx,4
add ebx,[esp+32]
inc word [esp+32]
mov al,[ebx]
mov dl,3
cmp al,0cch
je short v86int
cmp al,0ceh
jna .L1
jmp exc
.L1
je short v86genv86ni
inc word [esp+32]
mov dl,[ebx+1]
cmp dl,0fdh
jne short v86int
jmp retfromv86
v86genv86ni:
mov dl,4
v86int: ; Do interrupt for V86 task
mov ax,18h
mov ds,ax
movzx ebx,dl
shl ebx,2
movzx edx,word [esp+48]
shl edx,4
sub word [esp+44],6
add edx,[esp+44]
mov ax,[esp+40]
mov [edx+4],ax
mov ax,[esp+36]
mov [edx+2],ax
mov ax,[esp+32]
mov [edx],ax
and word [esp+40],0fcffh
mov eax,[ds:ebx]
mov [esp+32],ax
shr eax,16
mov [esp+36],ax
popad
iretd
Tom

Re:v86 help

Post by Tom »

Hurray!!!!!!!!!!! ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D

I have v86 working in my kernel!

TY for the help, I found the problem...it takes awhile for v86 to set ???

8) After it sets, the floppy light stops and the numlock works!

[glow=blue,2,300]Thank you for the tutorial[/glow]
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:v86 help

Post by Pype.Clicker »

yeah! well done! If you can zip your files and post them here (attachement), the next people that will face the V86 problem will be pleased to find them ;)
Tom

Re:v86 help

Post by Tom »

I DID find out that a simple bug in my loader just froze the computer in real mode and ... >:( you can guess.

I can get into v86 mode with that tutorial in DOS, but nothing else ( I changed EVERYTHING in that tutorial, but when I do it tripple-faults :o ).

So I have 3 ideas to make FritzOS, what one is best?:

1. Make FritzOS in Flat Real Mode ( have ints, 32-bit regs, and 4-Gig mem )

2. Make FritzOS use MS-DOS ( I can make it stable eventhough it has DOS...it was probly just MS who made win32 9x unstable ;) )

3. Better DOS idea...make my own version of FreeDOS to load FritzOS.

What would be a good Idea?

Instead of useing my own bootloader, that causes my v86 to crash, would one of those options work?

Thank you,
Tom

Re:v86 help

Post by Tom »

[attachment deleted by admin]
Tom

Re:v86 help

Post by Tom »

I give up... i'm making my OS in DOS using john fine's stuff.

now there's no use for my linux :o
Tim

Re:v86 help

Post by Tim »

Never give up! :)

If you can't get protected mode to work, you won't get very far otherwise: the challenges further down the road are harder.

My advice is to ignore V86 mode for now, get some simple protected mode code going, and build it up from there. You can get away without V86 mode for most things.
_Tom

Re:v86 help

Post by _Tom »

I ment I give up trying to make it in Linux.

I can get v86 on a bootsector floppy using John Fine's stuff.

I'm still making my OS, but I [glow=blue,2,300]need[/glow] v86 for my OS
Tim

Re:v86 help

Post by Tim »

You can do most things without using V86 mode. The only things you need it for are VESA, APM and running DOS programs (like DOSEMU and NT do). Direct hardware access replaces BIOS interrupts; in fact, using BIOS interrupts from protected mode is a bad idea.
Post Reply