Cant enable/use VESA lfb while Paging enabled

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
ashishkumar4
Member
Member
Posts: 73
Joined: Wed Dec 23, 2015 10:42 pm

Cant enable/use VESA lfb while Paging enabled

Post by ashishkumar4 »

I am making a simple OS currently (learning). I had made a vesa driver before which used napalm's v86 emulator to enable vesa. it works fine and I could use the linear frame buffer. However, After going through JamesM's tutorial on Paging, I Implemented it successfully while vesa was disabled. but as I try to use both (tried first enabling vesa then enabling paging in which I cant use lfb then, and tried enabling paging frst then vesa in which I cant use lfb in qemu though vesa screen initializes but it dosent initializes in VMware at all! ) I don't know too much about paging and assembly, if it may change anything, tried everything I knew, Please help me enabling both. just give me the solution straight away if possible. :( :'( Help me :'(
The best method for accelerating a computer is the one that boosts it by 9.8 m/s2.
My OS : https://github.com/AshishKumar4/Aqeous
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Cant enable/use VESA lfb while Paging enabled

Post by Brendan »

Hi,
ashishkumar4 wrote:I am making a simple OS currently (learning). I had made a vesa driver before which used napalm's v86 emulator to enable vesa. it works fine and I could use the linear frame buffer. However, After going through JamesM's tutorial on Paging, I Implemented it successfully while vesa was disabled. but as I try to use both (tried first enabling vesa then enabling paging in which I cant use lfb then, and tried enabling paging frst then vesa in which I cant use lfb in qemu though vesa screen initializes but it dosent initializes in VMware at all! ) I don't know too much about paging and assembly, if it may change anything, tried everything I knew, Please help me enabling both. just give me the solution straight away if possible. :( :'( Help me :'(
The real solution is to learn, so that you aren't relying on "cut & paste" and other people's (most likely dodgy and broken, and/or not well suited to your specific case) example code.

For James' Tutorial there's multiple known bugs. I don't think I've seen (and can't find) the code for napalm's v86 emulator; so I have no idea how many of the large number of possible corner-cases it gets wrong. I also can't see any of your code and don't know how you've integrated the dodgy tutorial with the unknown V86 emulator (and can't know how many "integration bugs" you've added on top of the pre-existing bugs).

All I can do is confirm that (in theory) it's possible to get it to work properly for both ways (for enabling paging and then using VBE and mapping the LFB into the virtual address space after; and for using VBE and then enable paging after).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
ashishkumar4
Member
Member
Posts: 73
Joined: Wed Dec 23, 2015 10:42 pm

Re: Cant enable/use VESA lfb while Paging enabled

Post by ashishkumar4 »

Thanks for reply lol :p here is my code if you can help
https://github.com/***removed****
and I know in theory that's possible, that's why I came here in that hope :p
Currently I did a thing which solved some of the problem. I just limited the paging to the address of lfb so that paging cant page addresses beyond that. Now I can plot pixels but only on SOME places on the screen and if I draw a background, I get a 2D array of red, green, blue pixels spaced with black spaces. that means I am still leaving some memory addresses paged :/ but cant find them. Also I don't know how to MAP lfb (not the theory, the practical because I came from a c# back and my friend one day told me "LETS MAKE AN OS IN ASM AND C :3 ") lol
Last edited by ashishkumar4 on Thu Dec 24, 2015 5:13 am, edited 1 time in total.
The best method for accelerating a computer is the one that boosts it by 9.8 m/s2.
My OS : https://github.com/AshishKumar4/Aqeous
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Cant enable/use VESA lfb while Paging enabled

Post by Brendan »

Hi,
ashishkumar4 wrote:Thanks for reply lol :p here is my code if you can help
https://github.com/AshishKumar4/Aqeous
I took a look at that branch, and couldn't find anything to do with v86 mode. The VESA code just uses an "int32()" function that isn't an interrupt and doesn't exist.

I searched and found "v86.asm" in a completely different (experimental) branch. This code doesn't use virtual8086 mode at all and switches between real mode and protected mode (and trashes the PICs and loses IRQs for no known reason).

I took a look at "vesa.c" and realised it's just assuming that "mode 0x117" might be a "1024*768 with 32-bpp" video mode without searching mode numbers for one that actually is "1024*768 with 32-bpp", without checking if "mode 0x117" exists or what it is, and without even checking if the mode was set correctly.

I took a look at "graphics.c" and noticed it doesn't use the "bytePerLine" field and therefore everything that writes pixels is broken.

It's like... Imagine a drunk guy "building" a car, who is actually just running around a car wrecking yard picking up random car parts and throwing them onto their "special" pile of junk. :roll:


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
FusT
Member
Member
Posts: 91
Joined: Wed Sep 19, 2012 3:43 am
Location: The Netherlands

Re: Cant enable/use VESA lfb while Paging enabled

Post by FusT »

Besides the stuff Brendan has mentioned I see you've practically copy-pasted JamesM's paging and heap code.
I'd strongly advise ripping all of that out, start reading up on paging and when you fully understand the concept write your own implementation. If it's not already causing you headaches, it will in the near future.
ashishkumar4
Member
Member
Posts: 73
Joined: Wed Dec 23, 2015 10:42 pm

Re: Cant enable/use VESA lfb while Paging enabled

Post by ashishkumar4 »

LOL k. Firstly, that experimental edition folder contains the copy of the os which I am working on currently and the code is not in good condition . secondly, I have separated them in different folders but they all still compile together and link at the same time ( check makefile ). thirdly because I got frustrated, I ripped away everything and just copy pasted jamesM's code in the hope that the thing I was writing had some errors :/ That's why you see they are just copy pasted. and The graphics.c was from my last project and I implemented it just to test if it works. And that I intentionally setted the 0x117 mode (you were right, its that mode) because I just wanted to make everything work. Currently I am not actually developing the os, I am just experimenting with things and reading and learning how they work.

Though you may find the problem is in my graphics code but trust me, when I disable paging, I get a clear blue background with a mouse pointer I made which works. that array like thing show on the screen when I switch on the paging.

I have copy pasted jamesM's paging, heap and multitasking code because I lost trust on myself and thought to JUST test it with what I have :p sorry for that but you know how it sucks when you just cant fix problems :/ sorry for copy pasting.
The best method for accelerating a computer is the one that boosts it by 9.8 m/s2.
My OS : https://github.com/AshishKumar4/Aqeous
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Cant enable/use VESA lfb while Paging enabled

Post by neon »

Hello,

I don't see where you are mapping vga_mem into the address space. It is set in vesa.c and used in graphics.c, but if its not mapped its going to page fault. The paging code appears to only identity map the low 16 MB region whereas the LFB is most probably in the upper 3 GB region. His code does not appear to implement any form of demand paging so once the page fault happens, its over. Assuming the above as the problem, you'll need to map the LFB into the address space.

If you were using Bochs you could easily verify this by using the info tab command. I know you want sample source code, however its dependent on your current paging code which really needs a redesign.

About the copying and pasting...The memory management code never goes away. It is such an important component of the overall system that it plays in every other part. Not being comfortable with the code is a disaster waiting to happen. If you are not comfortable with paging now, how do you think you'll be when you are still building things that use it a few years from now?
Also I don't know how to MAP lfb
Sorry, didn't quite see this one. Since you know what the problem is, you said that you understood the theory behind it, can you do paging by hand (I.e. know how to manually translate addresses) or do you think an example might be helpful? Or is the problem just putting it into code (general flow or using the tutorials code?)
Last edited by neon on Thu Dec 24, 2015 4:00 am, edited 2 times in total.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
ashishkumar4
Member
Member
Posts: 73
Joined: Wed Dec 23, 2015 10:42 pm

Re: Cant enable/use VESA lfb while Paging enabled

Post by ashishkumar4 »

the problem is just putting that into code. I made a new paging and mem alloc system. its working fine and I now how to make it working, thanks
The best method for accelerating a computer is the one that boosts it by 9.8 m/s2.
My OS : https://github.com/AshishKumar4/Aqeous
Post Reply