pritamzope / OS

Writing & Making Operating System and Kernel parts so simple like Hello World Programs, Starting from writing Bootloaders, Hello World Kernel, GDT, IDT, Terminal, Keyboard/Mouse, Memory Manager, HDD ATA R/W, VGA/VESA Graphics
http://createyourownos.blogspot.com
663 stars 103 forks source link

Using malloc and converting to 64bit #7

Closed EducatedMF closed 5 years ago

EducatedMF commented 5 years ago

Hello, Before anything else, thanks for the videos and this repo, awesome work! I managed to compile, print/read ints/strings and draw graphics. But now I want to convert the OS to 64bit, also when horsing around testing stuff, I tried using malloc and even though I have included stdlib.h I get : "....c:(.text+0x602): undefined reference to `malloc' " this is where I am trying to use malloc

`typedef struct _POINT_
{
    unsigned int x;
    unsigned int y;
}_POINT_;

struct _POINT_* POINT(const unsigned int _x, const unsigned int _y)
{
    struct _POINT_* point = (_POINT_*)malloc(sizeof(struct _POINT_));

    if(point)
    {
        point->x = _x;
        point->y = _y;
    }
    return point;
};`

Also can you provide more detail/reading material different than wikipedia on how vga_entry(...) works?

pritamzope commented 5 years ago

malloc() is a standard library function. it requires kernel system call brk() to perform its operations. you cannot just call it in kernel code because there are no system calls implemented yet. so first you have to write your own malloc() function.