Console implemtation based on VESA
Console implemtation based on VESA
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?
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?
Re:Console implemtation based on VESA
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.
Re:Console implemtation based on VESA
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.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.
as I said in BUCHS & VMWARE using VESA work fine,
Re:Console implemtation based on VESA
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!
here the code in my kernel which jump to my real mode code
I am note a assemply programmer
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
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
Re:Console implemtation based on VESA
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. :'(
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. :'(
Re:Console implemtation based on VESA
I call these functions on going and coming back from realmode to sort the pic problem
This one on going to realmode:
and on return this:
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.
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
Code: Select all
unmask_irqs:
mov al,0 ; unmask irq's
out 0xa1,al
out 0x21,al
sti
ret
Note: No paging is implemented.
Re:Console implemtation based on VESA
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.
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.
Re:Console implemtation based on VESA
I would be interested in that.Dex4u wrote: I call these functions on going and coming back from realmode to sort the pic problem
This one on going to realmode:and on return this:Code: Select all
mask_irqs: cli mov al,255 ; mask all irqs out 0xa1,al out 0x21,al 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.Code: Select all
unmask_irqs: mov al,0 ; unmask irq's out 0xa1,al out 0x21,al sti ret
Note: No paging is implemented.
Re:Console implemtation based on VESA
You can get it here: http://board.flatassembler.net/topic.php?p=22043#22043
Its called "VesaDemo.zip"
Its called "VesaDemo.zip"
Re:Console implemtation based on VESA
For some reason that only shows me that I'm in text mode when I test it in VMware. What is wrong?Dex4u wrote:You can get it here: http://board.flatassembler.net/topic.php?p=22043#22043
Its called "VesaDemo.zip"
Conway's Law: If you have four groups working on a compiler, you'll get a 4-pass compiler.
Melvin Conway
Melvin Conway
Re:Console implemtation based on VESA
I have not tested it in VMware, it works fine in broch or qemu or real pc.Wave wrote:For some reason that only shows me that I'm in text mode when I test it in VMware. What is wrong?Dex4u wrote:You can get it here: http://board.flatassembler.net/topic.php?p=22043#22043
Its called "VesaDemo.zip"
It will most likely be that VMware will need setting to use vesa, have you used vesa in VMware before ?.