mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
add hbmem support
This commit is contained in:
parent
8c8dac4038
commit
703992b6cf
6 changed files with 46 additions and 4 deletions
|
@ -67,6 +67,8 @@ align 4
|
|||
global header_size
|
||||
global disable_x2apic
|
||||
global mb_info
|
||||
global hbmem_base
|
||||
global hbmem_size
|
||||
base dq 0
|
||||
limit dq 0
|
||||
cpu_freq dd 0
|
||||
|
@ -88,6 +90,8 @@ align 4
|
|||
disable_x2apic dd 1
|
||||
single_kernel dd 1
|
||||
mb_info dq 0
|
||||
hbmem_base dq 0
|
||||
hbmem_size dq 0
|
||||
|
||||
; Bootstrap page tables are used during the initialization.
|
||||
align 4096
|
||||
|
|
|
@ -60,4 +60,28 @@ int put_pages(size_t phyaddr, size_t npages);
|
|||
*/
|
||||
static inline int put_page(size_t phyaddr) { return put_pages(phyaddr, 1); }
|
||||
|
||||
/** @brief Request physical hbmem page frames */
|
||||
size_t hbmem_get_pages(size_t npages);
|
||||
|
||||
/** @brief Get a single hbmem page
|
||||
*
|
||||
* Convenience function: uses hbmem_get_pages(1);
|
||||
*/
|
||||
static inline size_t hbmem_get_page(void) { return hbmem_get_pages(1); }
|
||||
|
||||
/** @brief release physical page frames */
|
||||
int hbmem_put_pages(size_t phyaddr, size_t npages);
|
||||
|
||||
/** @brief Put a single hbmem page
|
||||
*
|
||||
* Convenience function: uses hbmem_put_pages(1);
|
||||
*/
|
||||
static inline int hbmem_put_page(size_t phyaddr) { return hbmem_put_pages(phyaddr, 1); }
|
||||
|
||||
/** @brief check if high memory bandwidth is available */
|
||||
int is_hbmem_available(void);
|
||||
|
||||
/** @brief Initialize the high bandwidth memory subsystem */
|
||||
int hbmemory_init(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -80,6 +80,8 @@ extern const void percore_start;
|
|||
extern const void percore_end0;
|
||||
extern const void percore_end;
|
||||
extern char __BUILD_DATE;
|
||||
extern size_t hbmem_base;
|
||||
extern size_t hbmem_size;
|
||||
|
||||
/* Page frame counters */
|
||||
extern atomic_int64_t total_pages;
|
||||
|
@ -592,6 +594,8 @@ int hermit_main(void)
|
|||
kprintf("Current allocated memory: %zd KiB\n", atomic_int64_read(&total_allocated_pages) * PAGE_SIZE / 1024ULL);
|
||||
kprintf("Current available memory: %zd MiB\n", atomic_int64_read(&total_available_pages) * PAGE_SIZE / (1024ULL*1024ULL));
|
||||
kprintf("Core %d is the boot processor\n", boot_processor);
|
||||
if (hbmem_base)
|
||||
kprintf("Found high bandwidth memory at 0x%zx (size 0x%zx)\n", hbmem_base, hbmem_size);
|
||||
|
||||
#if 0
|
||||
print_pci_adapters();
|
||||
|
|
|
@ -496,7 +496,10 @@ int sys_rcce_init(int session_id)
|
|||
goto out;
|
||||
}
|
||||
|
||||
paddr = get_pages(RCCE_MPB_SIZE / PAGE_SIZE);
|
||||
if (is_hbmem_available())
|
||||
paddr = hbmem_get_pages(RCCE_MPB_SIZE / PAGE_SIZE);
|
||||
else
|
||||
paddr = get_pages(RCCE_MPB_SIZE / PAGE_SIZE);
|
||||
if (BUILTIN_EXPECT(!paddr, 0))
|
||||
{
|
||||
err = -ENOMEM;
|
||||
|
@ -592,8 +595,12 @@ int sys_rcce_fini(int session_id)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (rcce_mpb[i].mpb[isle])
|
||||
put_pages(rcce_mpb[i].mpb[isle], RCCE_MPB_SIZE / PAGE_SIZE);
|
||||
if (rcce_mpb[i].mpb[isle]) {
|
||||
if (is_hbmem_available())
|
||||
hbmem_put_pages(rcce_mpb[i].mpb[isle], RCCE_MPB_SIZE / PAGE_SIZE);
|
||||
else
|
||||
put_pages(rcce_mpb[i].mpb[isle], RCCE_MPB_SIZE / PAGE_SIZE);
|
||||
}
|
||||
rcce_mpb[i].mpb[isle] = 0;
|
||||
|
||||
for(j=0; (j<MAX_ISLE) && !rcce_mpb[i].mpb[j]; j++) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
C_source := memory.c malloc.c vma.c shm.c
|
||||
C_source := memory.c malloc.c vma.c shm.c hbmemory.c
|
||||
MODULE := mm
|
||||
|
||||
include $(TOPDIR)/Makefile.inc
|
||||
|
|
|
@ -305,6 +305,9 @@ int memory_init(void)
|
|||
|
||||
kprintf("free list starts at 0x%zx, limit 0x%zx\n", init_list.start, init_list.end);
|
||||
|
||||
// init high bandwidth memory subsystem
|
||||
hbmemory_init();
|
||||
|
||||
ret = vma_init();
|
||||
if (BUILTIN_EXPECT(ret, 0))
|
||||
kprintf("Failed to initialize VMA regions: %d\n", ret);
|
||||
|
|
Loading…
Add table
Reference in a new issue