Skip to content
This repository was archived by the owner on Jan 14, 2026. It is now read-only.

Commit 9a501a0

Browse files
committed
fix memory capacity
1 parent b3f7ef7 commit 9a501a0

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

src/include/mem/vmem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ typedef enum {
1414

1515
uint32_t vmem_virt_to_phys(uint32_t virt);
1616
uint32_t vmem_phys_to_virt(uint32_t phys);
17+
/* 64-bit helpers: return 64-bit physical/virtual addresses for kernels running in 64-bit mode.
18+
These wrap the 32-bit routines and zero-extend; replace with full 64-bit implementation when available. */
19+
uint64_t vmem_virt_to_phys64(uint64_t virt);
20+
uint64_t vmem_phys_to_virt64(uint64_t phys);
1721
void vmem_set_offset(int32_t offset);
1822
void vmem_reset(void);
1923
void vmem_set_mode(vmem_mode_t mode);

src/kernel/mem/manager.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ void memory_init() {
250250
uintptr_t heap_start = (base_end > bitmap_end) ? base_end : bitmap_end;
251251
// 4KBページ境界に切り上げてアライン
252252
heap_start = (heap_start + 0x0FFF) & ~0x0FFF;
253-
/* 増やす: ブロックキャッシュなどで大きな動的確保が必要になるためヒープを256KBに拡張 */
254-
uintptr_t heap_end = heap_start + 0x40000; // 256KBのヒープ領域
253+
uintptr_t heap_end = heap_start + 0x100000; // 1MBのヒープ領域
255254
mem_init((uint32_t)heap_start, (uint32_t)heap_end);
256255
memmap_reserve((uint32_t)heap_start, (uint32_t)heap_end);
257256
}

src/kernel/mem/vmem.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ uint32_t vmem_virt_to_phys(uint32_t virt) {
9090
return phys;
9191
}
9292

93+
/* 64-bit wrapper: call 32-bit virt->phys and zero-extend to 64-bit.
94+
This is a compatibility helper for subsystems that expect 64-bit DMA addresses.
95+
Replace with a true 64-bit page-table walk implementation if/when needed. */
96+
uint64_t vmem_virt_to_phys64(uint64_t virt) {
97+
uint32_t v32 = (uint32_t)virt;
98+
uint32_t p32 = vmem_virt_to_phys(v32);
99+
return (uint64_t)p32;
100+
}
101+
93102
// 物理アドレス→仮想アドレス変換
94103
uint32_t vmem_phys_to_virt(uint32_t phys) {
95104
/* Treat UINT32_MAX as error sentinel instead of 0 to allow phys==0 */
@@ -121,6 +130,12 @@ uint32_t vmem_phys_to_virt(uint32_t phys) {
121130
}
122131
}
123132

133+
uint64_t vmem_phys_to_virt64(uint64_t phys) {
134+
uint32_t p32 = (uint32_t)phys;
135+
uint32_t v32 = vmem_phys_to_virt(p32);
136+
return (uint64_t)v32;
137+
}
138+
124139
// オフセット設定
125140
void vmem_set_offset(int32_t offset) {
126141
vmem_offset = offset;

0 commit comments

Comments
 (0)