Skip to content

Commit 1c566f7

Browse files
committed
realize paging memory, add kmalloc aligned; todo: realize kmemdump fully
1 parent f606112 commit 1c566f7

File tree

5 files changed

+69
-6
lines changed

5 files changed

+69
-6
lines changed

CHANGELOG.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
1-
<<<<<<< HEAD
2-
<<<<<<< HEAD
1+
commit f606112b639b04e51fd6449516d295f348cb1cc7
2+
Author: Alexeev Bronislav <[email protected]>
3+
Date: Sun Aug 24 22:24:16 2025 +0700
4+
5+
realize paging memory, add kmalloc aligned; todo: realize kmemdump fully
6+
7+
commit 4f3b9d7ea973f1106a9afb68682d8abf371640e8
8+
Author: Alexeev Bronislav <[email protected]>
9+
Date: Sun Aug 24 22:22:55 2025 +0700
10+
11+
realize paging memory, add kmalloc aligned; todo: realize kmemdump fully
12+
13+
commit a4deb10c546b41616b0a8ffb9a58a27016704d22
14+
Author: Alexeev Bronislav <[email protected]>
15+
Date: Sun Aug 24 21:23:39 2025 +0700
16+
17+
replace paging
18+
19+
commit 87ef6daf677ce9a7451a29a1ad1a51858e8034cf
20+
Author: Alexeev Bronislav <[email protected]>
21+
Date: Sun Aug 24 06:23:40 2025 +0700
22+
23+
try fix paging; TODO: FIX PAGING AND FRAME ALLOC
24+
325
commit 5c5167c783467a1441565edfd12b130a741e999c
426
Author: Alexeev Bronislav <[email protected]>
527
Date: Sun Aug 24 06:05:27 2025 +0700
628

729
feat: realize paging, add page, frame allocator and change kfree, kmalloc, krealloc
830

9-
=======
10-
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
11-
=======
12-
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
1331
commit ffe676bbcd462e3e7d7c8bd82ca1683361ba3bf6
1432
Author: Alexeev Bronislav <[email protected]>
1533
Date: Sun Aug 24 04:06:51 2025 +0700

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ KERNEL_ENTRY = $(BIN_DIR)/bootloader/kernel_entry.o
1919
INTERRUPT_OBJ = $(BIN_DIR)/kernel/cpu/interrupt.o
2020
<<<<<<< HEAD
2121
<<<<<<< HEAD
22+
<<<<<<< HEAD
2223
PAGING_OBJ = $(BIN_DIR)/bootloader/paging.o
2324
=======
2425
PAGING_OBJ = $(BIN_DIR)/kernel/paging_asm.o
2526
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
2627
=======
2728
PAGING_OBJ = $(BIN_DIR)/kernel/paging_asm.o
2829
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
30+
=======
31+
PAGING_OBJ = $(BIN_DIR)/kernel/paging_asm.o
32+
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
2933

3034
C_SOURCES = $(shell find $(SRC_DIR) -name '*.c')
3135
C_OBJS = $(C_SOURCES:$(SRC_DIR)/%.c=$(BIN_DIR)/%.o)

src/kernel/kernel/kernel.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ void kmain() {
2525
irq_install();
2626
kprint("IRQ Installed\n");
2727

28+
<<<<<<< HEAD
2829
<<<<<<< HEAD
2930
init_paging();
31+
=======
32+
register_interrupt_handler(14, page_fault_handler);
33+
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
3034
=======
3135
register_interrupt_handler(14, page_fault_handler);
3236
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)

src/kernel/kklibc/mem.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,31 @@ void heap_init() {
3939
free_blocks->page = NULL;
4040

4141
kprint("Heap initialized at virtual: ");
42+
<<<<<<< HEAD
4243
kprint("Heap initialized at virtual: ");
44+
=======
45+
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
4346
char buf[32] = "";
4447
hex_to_ascii(HEAP_VIRTUAL_START, buf);
4548
kprint(buf);
4649
kprint(", physical: ");
4750
hex_to_ascii(heap_physical_start, buf);
51+
<<<<<<< HEAD
4852
hex_to_ascii(HEAP_VIRTUAL_START, buf);
4953
kprint(buf);
5054
kprint(", physical: ");
5155
hex_to_ascii(heap_physical_start, buf);
56+
=======
57+
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
5258
kprint(buf);
5359
kprint("\n");
5460
}
5561

5662

63+
<<<<<<< HEAD
5764

65+
=======
66+
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
5867
// TODO: Paging is not implemented
5968
void *get_physaddr(void *virtualaddr) {
6069
return get_physical_address(virtualaddr);
@@ -86,6 +95,7 @@ void *kmalloc_a(u32 size) {
8695
}
8796

8897
return virtual_addr;
98+
<<<<<<< HEAD
8999
return get_physical_address(virtualaddr);
90100
}
91101

@@ -115,6 +125,8 @@ void *kmalloc_a(u32 size) {
115125
}
116126

117127
return virtual_addr;
128+
=======
129+
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
118130
}
119131

120132
void *kmalloc(u32 size) {
@@ -164,7 +176,10 @@ void *kmalloc(u32 size) {
164176

165177
current->is_free = 0;
166178
return (void*)((u32)current + sizeof(mem_block_t));
179+
<<<<<<< HEAD
167180
return (void*)((u32)current + sizeof(mem_block_t));
181+
=======
182+
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
168183
}
169184
prev = current;
170185
current = current->next;
@@ -284,8 +299,11 @@ meminfo_t get_meminfo() {
284299

285300
meminfo.heap_virtual_start = HEAP_VIRTUAL_START;
286301
meminfo.heap_physical_start = heap_physical_start;
302+
<<<<<<< HEAD
287303
meminfo.heap_virtual_start = HEAP_VIRTUAL_START;
288304
meminfo.heap_physical_start = heap_physical_start;
305+
=======
306+
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
289307
meminfo.heap_size = HEAP_SIZE;
290308
meminfo.block_size = BLOCK_SIZE;
291309
meminfo.free_blocks = free_blocks;
@@ -299,17 +317,23 @@ meminfo_t get_meminfo() {
299317
meminfo.used_pages = 256; // Примерное значение
300318
meminfo.free_pages = 768; // Примерное значение
301319

320+
<<<<<<< HEAD
302321
// Информация о страницах (заглушка)
303322
meminfo.page_directory_phys = (u32)get_physical_address(get_current_page_directory());
304323
meminfo.total_pages = 1024; // Примерное значение
305324
meminfo.used_pages = 256; // Примерное значение
306325
meminfo.free_pages = 768; // Примерное значение
307326

327+
=======
328+
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
308329
return meminfo;
309330
}
310331

311332
// Дамп информации о памяти
333+
<<<<<<< HEAD
312334
// Дамп информации о памяти
335+
=======
336+
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
313337
void kmemdump() {
314338
meminfo_t info = get_meminfo();
315339
mem_block_t *current = info.free_blocks;
@@ -319,27 +343,36 @@ void kmemdump() {
319343
info.heap_virtual_start + info.heap_size, info.heap_size);
320344
kprintf("Heap: physical %x - %x\n", info.heap_physical_start,
321345
info.heap_physical_start + info.heap_size);
346+
<<<<<<< HEAD
322347
kprintf("Heap: virtual %x - %x (%d bytes)\n", info.heap_virtual_start,
323348
info.heap_virtual_start + info.heap_size, info.heap_size);
324349
kprintf("Heap: physical %x - %x\n", info.heap_physical_start,
325350
info.heap_physical_start + info.heap_size);
351+
=======
352+
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
326353
kprintf("Block size: %d bytes\n", info.block_size);
327354
kprintf("Total: USED=%d bytes, FREE=%d bytes, in %d blocks\n",
328355
info.total_used, info.total_free, info.block_count);
329356
kprintf("Pages: TOTAL=%d, USED=%d, FREE=%d\n\n",
330357
info.total_pages, info.used_pages, info.free_pages);
358+
<<<<<<< HEAD
331359
kprintf("Total: USED=%d bytes, FREE=%d bytes, in %d blocks\n",
332360
info.total_used, info.total_free, info.block_count);
333361
kprintf("Pages: TOTAL=%d, USED=%d, FREE=%d\n\n",
334362
info.total_pages, info.used_pages, info.free_pages);
363+
=======
364+
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
335365

336366
while (current) {
337367
kprintf("Block %d: virt=%x, phys=%x, Size=%d, %s\n", counter++,
338368
(u32)current, (u32)get_physical_address(current),
339369
current->size, current->is_free ? "FREE" : "USED");
370+
<<<<<<< HEAD
340371
kprintf("Block %d: virt=%x, phys=%x, Size=%d, %s\n", counter++,
341372
(u32)current, (u32)get_physical_address(current),
342373
current->size, current->is_free ? "FREE" : "USED");
374+
=======
375+
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
343376
current = current->next;
344377
}
345378

src/kernel/kklibc/mem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ typedef struct meminfo {
5151
void *get_physaddr(void *virtualaddr);
5252
meminfo_t get_meminfo();
5353
<<<<<<< HEAD
54+
<<<<<<< HEAD
5455

56+
=======
57+
void get_freememaddr();
58+
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)
5559
=======
5660
void get_freememaddr();
5761
>>>>>>> 3fe2ead (realize paging memory, add kmalloc aligned; todo: realize kmemdump fully)

0 commit comments

Comments
 (0)