int 86

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

Post by eddyb »

for this I get coprocessor fault exception

Code: Select all

asm("movb $0x00, %ah\n\t"
			"movb $0x13, %al\n\t"
			"int $0x10"
			);
If i put only the intrerupt, i get breakpoint exception
Why?

LE:
no, depends on the intrerupt
0x00-division by zero
0x03-breakpoint exception
0x03-coproccesor fault

LLE: Ha Ha HA :P :P :P :) :) :) :D :D :D

that's because that:

Code: Select all

unsigned char *exception_messages[] =
{
    "Division By Zero",
    "Debug",
    "Non Maskable Interrupt",
    "Breakpoint",
    "Into Detected Overflow",
    "Out of Bounds",
    "Invalid Opcode",
    "No Coprocessor",

    "Double Fault",
    "Coprocessor Segment Overrun",
    "Bad TSS",
    "Segment Not Present",
    "Stack Fault",
    "General Protection Fault",
    "Page Fault",
    "Unknown Interrupt",

    "Coprocessor Fault",
    "Alignment Check",
    "Machine Check",
    "Reserved",
    "Reserved",
    "Reserved",
    "Reserved",
    "Reserved",

    "Reserved",
    "Reserved",
    "Reserved",
    "Reserved",
    "Reserved",
    "Reserved",
    "Reserved",
    "Reserved"
};

/* All of our Exception handling Interrupt Service Routines will
*  point to this function. This will tell us what exception has
*  happened! Right now, we simply halt the system by hitting an
*  endless loop. All ISRs disable interrupts while they are being
*  serviced as a 'locking' mechanism to prevent an IRQ from
*  happening and messing up kernel data structures */
void fault_handler(struct iregs *r)
{
    if (r->int_no < 32)
    {
        puts(exception_messages[r->int_no]);
        puts(" Exception. System Halted!\n");
        for (;;);
    }
}
but why i cant use a video intrerupt?
why all intrerupts are assigned to error messages? :?
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

You are in protected mode. The BIOS interrupts are only valid in real mode. You need v86 mode or you need to switch back to real mode in order to get BIOS ints to work. See the wiki for this.

Cheers,
Adam
eddyb

Post by eddyb »

:cry: :cry: :cry: :cry: I can enable int in pmode?
I readed somewhere that i can :?
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

In protected mode, the interrupt handling system is different.

In real mode, you have an IVT at the start of RAM. The actual interrupt handlers are provided by the BIOS for you (they are there to assist the OS). Because it is real mode, they use (seg * 0x10) + offset addressing and have 16 bit code. The BIOS will also assume it can make use of hardware interrupts for a given device.

In 32 bit PMode or 64 bit long mode, you have an IDT whose address and size you have provided for IDTR. The CPU looks up what code it should run in what privilege mode in your IDT. This code must be 32 or 64 bit (depending what mode you are in) and uses (pmode segment selector):offset addressing. Thus, you cannot directly use BIOS interrupts in long or pmode.

The exception to this is v86 mode, which is accessible from 32 bit protected mode. You set up a protected mode task which has its VM bit set (EFLAGS). Any task running in this mode acts exactly like a real mode task (except it cannot switch to pmode) with the addition of seeing paged RAM as physical RAM, if your OS has set it up. As long as you have preserved memory addresses 0-0x500 and physical RAM in your BIOS area is identity mapped, you can again call BIOS interrupts. For this, you will have to write a v86 monitor and/or use Virtual Mode Extensions.

The free Intel manuals provide a wealth of valuable information on modes (but not on BIOS functions!).

Cheers,
Adam
eddyb

Post by eddyb »

how i can set v8086 mode?
What code i need to have in my code?

Code: Select all

; This is the kernel's entry point. We could either call main here,
; or we can use this to setup the stack or other nice stuff, like
; perhaps setting up the GDT and segments. Please note that interrupts
; are disabled at this point: More on interrupts later!
[BITS 32]
global start
start:
    mov esp, _sys_stack     ; This points the stack to our new stack area
    jmp stublet

; This part MUST be 4byte aligned, so we solve that issue using 'ALIGN 4'
ALIGN 4
mboot:
    ; Multiboot macros to make a few lines later more readable
    MULTIBOOT_PAGE_ALIGN	equ 1<<0
    MULTIBOOT_MEMORY_INFO	equ 1<<1
    MULTIBOOT_AOUT_KLUDGE	equ 1<<16
    MULTIBOOT_HEADER_MAGIC	equ 0x1BADB002
    MULTIBOOT_HEADER_FLAGS	equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
    MULTIBOOT_CHECKSUM	equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
    EXTERN code, bss, end

    ; This is the GRUB Multiboot header. A boot signature
    dd MULTIBOOT_HEADER_MAGIC
    dd MULTIBOOT_HEADER_FLAGS
    dd MULTIBOOT_CHECKSUM
    
    ; AOUT kludge - must be physical addresses. Make a note of these:
    ; The linker script fills in the data for these ones!
    dd mboot
    dd code
    dd bss
    dd end
    dd start

; This is an endless loop here. Make a note of this: Later on, we
; will insert an 'extern _main', followed by 'call _main', right
; before the 'jmp $'.
stublet:
	extern _main
	
    call _main
    jmp $
I think i need to put the new code before call _main(extern c function)
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

See http://www.osdev.org/wiki/Virtual_Monitor and http://www.osdev.org/wiki/Virtual_8086_Mode, which will get you started. I'm afraid that no-one is going to write you code for either switching back to real mode or using v86 - you need to read up about that.

There's plenty on the wiki and if you search the forums, Dex has provided some useful links in the past, IIRC.

Cheers,
Adam
eddyb

Post by eddyb »

but how i can use video from pmode? (without unsing v8086 mode)
can you rewrite the code from http://www.brackeen.com/vga/basics.html
to don't use anymore int86()?
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

No.

If you want VGA, fine - you need to read up on VGA specs and adjust registers yourself as per the specs (for a VGA compatible card). If you want SVGA or better, you need to use VESA.

To switch in to a VESA supported mode, you need int 0x10, AX=0x4Fxx as per the VESA specs. For this, you need to use vm86 or real mode. After you have done this, access VESA memory with a LFB or using the VESA protected mode interface.

VGA and VESA are well documented and specifications are freely available. You will not often find anyone who is prepared to completely translate/write code for you. You need to read and understand the docs and do the work yourself. If there is anything specific you then don't understand and need support with, I'm sure people on the forum will be only too glad to help you.

Cheers,
Adam
eddyb

Post by eddyb »

i can enter v8086, execute something and exit this mode, whitout implementation problems?

I think i can enter this mode for a while, to switch visual modes.

Also, i can enter by default v8086 with osdever bran's kernel?
I'm refering at modules(idt, irq, gdt, etc) not at code
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

Read this book 5 times cover to cover, then ask again.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
eddyb

Post by eddyb »

:cry: :cry: :cry: :cry: :cry: :cry: :cry:
Is too hard this homework!
:D
eddyb

Post by eddyb »

now serious:
i have a kernel like this
Which modules and which not are compatible with v8068?
how i can enter this mode?[/wiki]
eddyb

Post by eddyb »

give me a solution
1)how to enter by default v8086 with my kernel
OR
2) give me an example of video driver using only in and out
And WTF is www.vesa.org? there ins't any documentation!
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Post by ~ »

Entering v86 mode is not a simple task. It requires several setups and your kernel to be well structured.

I have such code using only IN and OUT, but it's all messed up, I don't have it by hand by now; it would take a while for me to order it in an useable form.

However, you can find code here, near where it says "Getting the card in the right mode":

http://www.qnx.org/developers/docs/qnx_ ... embed.html

And, from my experience, I have never been able to find some simple documentation at VESA.ORG for a simple or readily useable explanation for this kind of requests.

At least not for free:

http://www.vesa.org/Standards/summary/1998_9a.htm

I'd rather be looking for such documents somewhere else, where I could find them for free.
Last edited by ~ on Tue Feb 26, 2008 2:58 am, edited 1 time in total.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

eddyb wrote:give me a solution
That attitude really isn't helping. You need to learn how to use search engines - on this site and google.
1)how to enter by default v8086 with my kernel
Add multitasking support to your current kernel. Then come back and ask more specific questions, because you will be more ready to use v86.
OR
2) give me an example of video driver using only in and out
http://intellinuxgraphics.org/index.html. Have fun :roll:
And WTF is www.vesa.org? there ins't any documentation!
Have a look here, specifically the first two hits. Wasn't that difficult now, was it?
Locked