Am I using this memory correctly?
Posted: Thu Oct 22, 2015 6:59 pm
I have the following output when iterating the memory map:
Since I don't have any sort of memory management, I wanted to see if I could use the memory directly.
This just gives me a blank screen though. Is there something special I need to do before I can start using the memory?
<hr />
EDIT:
OK, looks like it was just slow. I changed the distance to 0x40. Maybe I need to optimize my mem* functions?
The issue is I've heard two pieces of information: GCC's built-in mem* are very fast, but since it's not always called, I need to provide my own mem*. If copying/setting is always going to be this slow, it's unfeasible for me not to write directly to video memory. Any tips?
Code: Select all
size = 14, base_addr = 0, length = 9fc00, type = available
size = 14, base_addr = 9fc00, length = 400, type = reserved
size = 14, base_addr = f0000, length = 10000, type = reserved
size = 14, base_addr = 100000, length = 7ee0000, type = available
size = 14, base_addr = 7fe0000, length = 20000, type = reserved
size = 14, base_addr = fffc0000, length = 40000, type = reserved
Code: Select all
auto free_mem_start = (uint8_t*) 0x100000;
auto free_mem_end = (uint8_t*) 0x7ee0000;
auto dist = free_mem_end - free_mem_start;
memset(free_mem_start, 0, dist);
auto pos = 0 * vbe->LinBytesPerScanLine + 0 * (vbe->bpp / 8);
auto color = 0xFF0000;
free_mem_start[pos] = color & 0xFF;
free_mem_start[pos + 1] = (color >> 8) & 0xFF;
free_mem_start[pos + 2] = (color >> 16) & 0xFF;
mem[pos] = free_mem_start[pos];
mem[pos + 1] = free_mem_start[pos + 1];
mem[pos + 2] = free_mem_start[pos + 2];
<hr />
EDIT:
OK, looks like it was just slow. I changed the distance to 0x40. Maybe I need to optimize my mem* functions?
Code: Select all
void *memset(void *s, int c, size_t n)
{
unsigned char* p= (unsigned char*)s;
while(n--)
*p++ = (unsigned char)c;
return s;
}
void *memcpy(void *dest, const void *src, size_t n)
{
char *dp = (char *)dest;
const char *sp = (const char *)src;
while (n--)
*dp++ = *sp++;
return dest;
}