view kernel/memory.c3 @ 408:ad6be5454067

Added image build task
author Windel Bouwman
date Sat, 21 Feb 2015 12:17:47 +0100
parents 0fb6633c42f6
children 6aa9743ed362
line wrap: on
line source

module memory;

import arch;
import io;

var int ptr;

// Let the heap grow upwards..

function void init()
{
    ptr = 0x60080000;
}

function byte* alloc(int size)
{
    var int ptr2;
    ptr2 = ptr;

    io.print2("alloc size ", size);
    io.print2("alloc address ", ptr);

    // Increment new free point:
    ptr = ptr + size;
    return ptr2;
}

function byte* allocate_physical()
{
    return 0;
}

function byte* allocate_virtual(byte* address)
{
    var byte* address2;
    address2 = allocate_physical();
    return address2;
}

function void memcpy(byte* dst, byte* src, int size)
{
    var int i;
    io.print2("memcpy to ", cast<int>(dst));
    io.print2("memcpy from ", cast<int>(src));
    for (i = 0; i < size; i += 1)
    {
        *(dst + i) = *(src + i);
    }
}