Skip to content
Snippets Groups Projects
Commit 5246f7c5 authored by Stephen D's avatar Stephen D
Browse files

Very, very simple malloc

parent 9eb90fd0
Branches master
No related tags found
No related merge requests found
......@@ -50,10 +50,7 @@ void main() {
register_commands();
/*char buffer[0x4800];
strcpy(buffer, "writing this to the floppy drive");
floppy_write_track(4, buffer);
println(buffer);*/
disk_cmd_init();
while(1)
{
......
#include "mem.h"
void memory_copy(u8 *source, u8 *dest, int nbytes) {
void memory_copy(u8 *source, u8 *dest, int nbytes)
{
int i;
for (i = 0; i < nbytes; i++) {
*(dest + i) = *(source + i);
}
}
void memory_set(u8 *dest, u8 val, u32 len) {
void memory_set(u8 *dest, u8 val, u32 len)
{
u8 *temp = (u8 *)dest;
for ( ; len != 0; len--) *temp++ = val;
}
//TODO:
//free()
//alignment
const u32 start_addr = 0x100000;
u32 cur_addr = start_addr;
const u32 end_addr = 0x10000000;
u32 malloc(u32 len)
{
u32 addr = cur_addr;
cur_addr += len;
return addr;
}
......@@ -5,5 +5,6 @@
void memory_copy(u8 *source, u8 *dest, int nbytes);
void memory_set(u8 *dest, u8 val, u32 len);
u32 malloc(u32 len);
#endif
......@@ -5,6 +5,7 @@
#include "../libc/string.h"
#include "../programs/texteditor.h"
#include "../drivers/floppy.h"
#include "../libc/mem.h"
void help(char *args)
{
......@@ -101,7 +102,12 @@ void video_debug(char *args)
}
}*/
char buffer[0x4800];
char *buffer;
void disk_cmd_init()
{
buffer = (char *)malloc(0x4800);
}
void read_callback(int p)
{
......
#ifndef commands
#define commands
void register_commands();
void disk_cmd_init();
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment