mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-15 23:47:25 -04:00
Prepare malloc support
This commit is contained in:
parent
edf57ba352
commit
eafbf23b6e
20
userlib/include/malloc.hpp
Normal file
20
userlib/include/malloc.hpp
Normal file
@ -0,0 +1,20 @@
|
||||
//=======================================================================
|
||||
// Copyright Baptiste Wicht 2013-2014.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//=======================================================================
|
||||
|
||||
#ifndef USERLIB_MALLOC_H
|
||||
#define USERLIB_MALLOC_H
|
||||
|
||||
#include "types.hpp"
|
||||
|
||||
void* malloc(size_t size);
|
||||
void free(void* pointer);
|
||||
|
||||
size_t brk_start();
|
||||
size_t brk_end();
|
||||
size_t sbrk(size_t inc);
|
||||
|
||||
#endif
|
45
userlib/src/malloc.cpp
Normal file
45
userlib/src/malloc.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
//=======================================================================
|
||||
// Copyright Baptiste Wicht 2013-2014.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//=======================================================================
|
||||
|
||||
#include "malloc.hpp"
|
||||
|
||||
void* malloc(size_t size){
|
||||
//TODO
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void free(void* pointer){
|
||||
//TODO
|
||||
}
|
||||
|
||||
size_t brk_start(){
|
||||
size_t value;
|
||||
asm volatile("mov rax, 7; int 50; mov %0, rax"
|
||||
: "=m" (value)
|
||||
: //No inputs
|
||||
: "rax");
|
||||
return value;
|
||||
}
|
||||
|
||||
size_t brk_end(){
|
||||
size_t value;
|
||||
asm volatile("mov rax, 8; int 50; mov %0, rax"
|
||||
: "=m" (value)
|
||||
: //No inputs
|
||||
: "rax");
|
||||
return value;
|
||||
}
|
||||
|
||||
size_t sbrk(size_t inc){
|
||||
size_t value;
|
||||
asm volatile("mov rax, 9; int 50; mov %0, rax"
|
||||
: "=m" (value)
|
||||
: "b" (inc)
|
||||
: "rax");
|
||||
return value;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user