Add hulk.linker_addresses module

This commit is contained in:
Josh Holtrop 2022-04-26 19:37:05 -04:00
parent bf9a005dbc
commit 153a8d43f1
3 changed files with 60 additions and 12 deletions

View File

@ -6,8 +6,7 @@ module hulk.hippo;
import hulk.header;
import hulk.bootinfo;
import hulk.klog;
extern extern(C) ubyte * _hulk_bss_size;
import hulk.linker_addresses;
struct hippo
{
@ -50,7 +49,7 @@ struct hippo
size_t usable_memory;
ulong[2][5] reserved = [
[header.bootinfo.hulk_phys, cast(ulong)header.total_size],
[header.bootinfo.bss_phys, cast(ulong)&_hulk_bss_size],
[header.bootinfo.bss_phys, LinkerAddresses.hulk_bss_size],
[header.bootinfo.stack_phys, header.stack_size],
[cast(ulong)header.bootinfo.fb.buffer, header.bootinfo.fb.height * header.bootinfo.fb.stride],
[header.bootinfo.pt_phys, header.bootinfo.pt_size],

View File

@ -3,37 +3,45 @@ SECTIONS
. = 0xFFFF800000000000;
_hulk_mem_start = .;
.hulk_header BLOCK(4K) : ALIGN(4K)
.hulk_header :
{
*(.hulk_header)
}
_hulk_header_size = . - _hulk_mem_start;
.text BLOCK(4K) : ALIGN(4K)
. = ALIGN(4K);
_hulk_text_start = .;
.text :
{
*(.text)
}
.rodata BLOCK(4K) : ALIGN(4K)
. = ALIGN(4K);
_hulk_text_end = .;
.rodata :
{
*(.rodata)
}
.data BLOCK(4K) : ALIGN(4K)
. = ALIGN(4K);
.data :
{
*(.data)
}
.bss BLOCK(4K) : ALIGN(4K)
. = ALIGN(4K);
_hulk_bss_start = .;
.bss :
{
_hulk_bss_start = .;
*(COMMON)
*(.bss)
}
_hulk_bss_size = . - _hulk_bss_start;
. = ALIGN(4K);
_hulk_bss_size = . - _hulk_bss_start;
_hulk_mem_end = .;
_hulk_total_size = _hulk_mem_end - _hulk_mem_start;
}

View File

@ -0,0 +1,41 @@
/**
* This module provides access to linker-defined symbols.
*/
module hulk.linker_addresses;
private extern extern(C) __gshared ubyte _hulk_mem_start;
private extern extern(C) __gshared ubyte _hulk_bss_start;
private extern extern(C) __gshared ubyte _hulk_bss_size;
private extern extern(C) __gshared ubyte _hulk_mem_end;
private extern extern(C) __gshared ubyte _hulk_total_size;
/**
* This struct provides access to linker-defined symbols.
*/
public struct LinkerAddresses
{
public static @property ulong hulk_mem_start()
{
return cast(ulong)&_hulk_mem_start;
}
public static @property ulong hulk_bss_start()
{
return cast(ulong)&_hulk_bss_start;
}
public static @property ulong hulk_bss_size()
{
return cast(ulong)&_hulk_bss_size;
}
public static @property ulong hulk_mem_end()
{
return cast(ulong)&_hulk_mem_end;
}
public static @property ulong hulk_total_size()
{
return cast(ulong)&_hulk_total_size;
}
}