Calloc() and VBE... Need help.

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator:Moderators

Post Reply
User avatar
linuxfreak
Posts:52
Joined:Tue Jul 26, 2011 7:36 pm
Location:Paarl, Western Cape, South Africa
Calloc() and VBE... Need help.

Post by linuxfreak » Thu Jul 05, 2012 1:02 pm

Hello:
So the other day I started developing again(after my Windows problems), and I started with Graphics. The code in the Graphics tutorial here are for 16-bit real mode, and not 32-bit protected mode or 64-bit long mode, so I Googled for protected mode VBE info and found this and started implementing it, after adding the VBE and GFX interface, I noticed that "calloc()" and "free()" are used, and was wondering if it is possible to implement these functions with the current memory manager and code-base. I know I don't even have proper single or multitasking but, I know every one of us wants sparkling graphics for our OS.

While writing this, I thought about the James Molloy kernel development tutorials and it's multitasking tutorials, and I remember that an ordered array was used. I was wondering how to implement it, 'cause the one over there is C and I didn't compile properly.

Regards:
Jean-Pierre

legenddairy
Posts:2
Joined:Mon Jul 02, 2012 3:37 pm

Re: Calloc() and VBE... Need help.

Post by legenddairy » Fri Jul 06, 2012 5:24 pm

For the moment the series hasn't got a memory manager that supports malloc(i.e. it hasn't got a heap), so you have to options:
* Adapt the code to work with the vmmngr_alloc_page () and vmmngr_free_page () functions and waste a lot of memory
* Or make your own memory manager; this'll take some time but it's necessary for a good kernel so you might as well do it now :) Here's an example of a malloc implementation:
http://code.google.com/p/jamesm-tutoria ... src/heap.c
http://code.google.com/p/jamesm-tutoria ... src/heap.h

It may seem very complicated but it's actually pretty simple, just take a very good look at it.

User avatar
linuxfreak
Posts:52
Joined:Tue Jul 26, 2011 7:36 pm
Location:Paarl, Western Cape, South Africa

Re: Calloc() and VBE... Need help.

Post by linuxfreak » Sat Jul 07, 2012 9:38 am

Hi, thanks for your reply.

I also thought that I should create a new memory manager or at least upgrade the current one, but I was also looking for an example of those routines posted previously, it's just, when I downloaded the JamesM's Kernel Development Tutorial files, the heap tutorial seemed so integrated with the rest of the development kernel, that it seemed impossible to port to my OS, but with the links you supplied it seems more possible, thanks.

I also need realloc(), but I found the Microsoft implementation in the Visual Studio directory, I actually found the realloc.c file! , and realloc is just malloc() and free() combined, am I right. It just saves the data specified when calling realloc(), then free()'s the memory occupied by the previous data and malloc()'s the saved data again, well that's the way I understand it.

Regards
Jean-Pierre:
The Anti-Microsoft revolution has begun, and soon Apple will take over the universe. The world is primed for war - someone should just take the first blow.

Post Reply