Console implemtation based on VESA

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
amirsadig

Console implemtation based on VESA

Post by amirsadig »

I have implement a TTY console which can work with normal text mode or VESA mode. my kernel during initialization read all available VESA mode. this done by activate real mode and call 16 bit code which do all the work I need to access VESA in real mode. so I am not depending of any other tool to set for the VBE mode I need.

everything in BUCHS & VMWARE work as expected, but in real PC my kernel it crash with traditional error ;D (page fault) #14 after reading VBE modes (I have not yet set the video mode example 800x600).
when deactivate VBE in my kernel and use only the text mode, every thing work fine.

have someone any issues I should notice with VESA and the real PC when developing with it?
which mechanism you use to support VESA in your kernel?
DruG5t0r3

Re:Console implemtation based on VESA

Post by DruG5t0r3 »

So if I understand well, after coming back from real mode after getting all the available VESA modes you get a Page fault?. Most probably means that you are accessing or executing code/data that isn't mapped by your page table. Or maybe you didn't reinitialise paging properly. My guess is that you stored all those VESA modes somewhere in memory and that when in Protected mode you try to access them you get page fault.
amirsadig

Re:Console implemtation based on VESA

Post by amirsadig »

maybe you didn't reinitialise paging properly. My guess is that you stored all those VESA modes somewhere in memory and that when in Protected mode you try to access them you get page fault.
I can't guess this, because I got all modes and I list (print it on screen) the wanted mode , all this happend in protected mode with paging enabled.
as I said in BUCHS & VMWARE using VESA work fine,
amirsadig

Re:Console implemtation based on VESA

Post by amirsadig »

here is the 32/16 code I use to get/set the video mode. this code are loaded by boot loader and my kernel move it then to address x1000. did I done somewrong? note that in my kernel this code has been called to twice one time to get modes and secondly to set modes and both has been executed successfully, after that page faul appear!

Code: Select all

org     0x1000  
SECTION .text

[BITS 32]
vbe_main
      ;push eax
      ;cli
; ------ Ensure that code- and stack-segment limits are 64KB.
      push    ebx
      push   ecx
      mov   ebx,eax
      mov   eax, 40h
      mov   ss, eax
      jmp   dword 38h:return.2
return:
      pop     ecx
      pop     ebx
      retf
[BITS 16]
; ------ Disable protected mode; jump to real-mode segment.
    .2:
      mov   eax, cr0
                and   eax, 0xFE
                mov   cr0, eax
                jmp   word 0x00:.3
; ------ Load stack- and data-segment registers
; ------ with proper real-mode segment numbers.
   .3:      
         xor   ax, ax
           mov   ds, ax
      mov   es, ax
      mov   fs, ax
      mov   gs, ax
      ;mov   ax, 0x1000
       mov   ss, ax
      ;mov sp,0xFFF8      ; Load IP SI DI SP BP
      ;xor bp,bp
      sidt [idt_ptr1]
      lidt [idt_ptr]
      cmp   bx, 1
      je      get_mode
      cmp   bx, 2
      je      set_mode
      jmp   return_pm

get_mode:
      mov    ax, 4F01h
      ;mov    cx, 140h
      mov    di, 2000h
      int    10h
      jmp   return_pm
set_mode:
      mov    ax, 4F02h
      mov    bx, cx
      int    10h
      jmp   return_pm
get_pixel_clock:
      mov    ax, 4F0Bh
      mov    bx, cx
      int    10h
      jmp   return_pm
return_pm:
; return to PM

      mov   eax, cr0
      or   al, 1
      mov   cr0, eax
      ;lidt [idt_ptr1]
      mov    ax,10h
      mov    ds,ax
      mov    es,ax
      mov    ss,ax
      mov    fs,ax
      mov    gs,ax
      ;mov eax, [ptr_code]
      jmp    0x18:return
      
SECTION .data      
idt_ptr:
   dw 0xFFFF      ; IDT limit
   dd 0
idt_ptr1:
   dw 0xFFFF      ; IDT limit
   dd 0
 
here the code in my kernel which jump to my real mode code

Code: Select all

vbe_real_code:
      push ebp
      mov ebp, esp
      mov eax, [ebp+8]
      mov ecx, [ebp+12]
      call   0x18:0x1000
      lgdt [gdt_ptr]
      lidt [idt_ptr]
      pop ebp
      retn
I am note a assemply programmer :D
amirsadig

Re:Console implemtation based on VESA

Post by amirsadig »

I have catch my problem :-[. it is also as usual ;a forgotten code I have done before a while. normaly my kernel use the address oxD0000000 as start for HEAP and memory management for kernel. unfortuantly my graphic card uses this address also as their physical address of framebuffer. what I do always, is maping this framebuffer to a virtual address equal to framebuffer address. in this my kernel is currupted and thus I fall on page fault.
secondly after switch to realmode and go back to pmode I should reinitialize PIC again, or timer and keyboard and FDC doesn't work. this happend only on my real PC. :'(
Dex4u

Re:Console implemtation based on VESA

Post by Dex4u »

I call these functions on going and coming back from realmode to sort the pic problem
This one on going to realmode:

Code: Select all

mask_irqs:
        cli
        mov  al,255       ; mask all irqs
        out  0xa1,al
        out  0x21,al
        ret
and on return this:

Code: Select all

unmask_irqs:
        mov  al,0         ; unmask irq's
        out  0xa1,al
        out  0x21,al
        sti
        ret
I have made a demo for going to and from realmode and enable vesa, with asm code, if you want to take a look let me know.
Note: No paging is implemented.
amirsadig

Re:Console implemtation based on VESA

Post by amirsadig »

many thanks.
I have got VESA to run on any 32 bits mode. I also added to it 7 virtual console, all console now support some sort of posix terminal specification and application can control their terminal throw termios structure (throw syscall).
I will devide my consoles such as 1 for kernel shell (adminstrative shell) and console 2 .. 4 for text mode applications and console 5 will be the GUI, which I study now how to implement it.
Pointer

Re:Console implemtation based on VESA

Post by Pointer »

Dex4u wrote: I call these functions on going and coming back from realmode to sort the pic problem
This one on going to realmode:

Code: Select all

mask_irqs:
        cli
        mov  al,255       ; mask all irqs
        out  0xa1,al
        out  0x21,al
        ret
and on return this:

Code: Select all

unmask_irqs:
        mov  al,0         ; unmask irq's
        out  0xa1,al
        out  0x21,al
        sti
        ret
I have made a demo for going to and from realmode and enable vesa, with asm code, if you want to take a look let me know.
Note: No paging is implemented.
I would be interested in that.
Dex4u

Re:Console implemtation based on VESA

Post by Dex4u »

You can get it here: http://board.flatassembler.net/topic.php?p=22043#22043

Its called "VesaDemo.zip"
User avatar
Wave
Member
Member
Posts: 50
Joined: Sun Jan 20, 2008 5:51 am

Re:Console implemtation based on VESA

Post by Wave »

Dex4u wrote:You can get it here: http://board.flatassembler.net/topic.php?p=22043#22043

Its called "VesaDemo.zip"
For some reason that only shows me that I'm in text mode when I test it in VMware. What is wrong?
Conway's Law: If you have four groups working on a compiler, you'll get a 4-pass compiler.
Melvin Conway
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

could you not have messaged him rather than dragging up a topic over two years old?
~ Lukem95 [ Cake ]
Release: 0.08b
Image
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re:Console implemtation based on VESA

Post by Dex »

Wave wrote:
Dex4u wrote:You can get it here: http://board.flatassembler.net/topic.php?p=22043#22043

Its called "VesaDemo.zip"
For some reason that only shows me that I'm in text mode when I test it in VMware. What is wrong?
I have not tested it in VMware, it works fine in broch or qemu or real pc.
It will most likely be that VMware will need setting to use vesa, have you used vesa in VMware before ?.
User avatar
Wave
Member
Member
Posts: 50
Joined: Sun Jan 20, 2008 5:51 am

Post by Wave »

Not my own code. But other ("real") vesa drivers work.
Conway's Law: If you have four groups working on a compiler, you'll get a 4-pass compiler.
Melvin Conway
Post Reply