Skip to content

Commit 17e5cda

Browse files
committed
Update
1 parent 2ce94b5 commit 17e5cda

File tree

8 files changed

+17
-13
lines changed

8 files changed

+17
-13
lines changed

devlog/devlog20200306.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,12 @@
5555

5656
alloc_page 基本完成
5757

58+
59+
60+
# SimpleKernel 开发日志 20200406
61+
62+
好久没有更新,先回顾一下进度:为了配合 `task_pcb_t * get_current_task(void)` 函数,需要实现分配对齐到指定粒度的内存申请函数,目前的解决方案是在 vmm 里添加这个函数,现在要解决的问题是从理论上证明它可以与其它内存分配函数和谐共存。
63+
64+
- 将内核栈大小调整为 8KB
65+
- 删除之前写的内核栈分配函数
66+

iso/boot/kernel.bin

-396 Bytes
Binary file not shown.

simplekernel.iso

-2 KB
Binary file not shown.

src/arch/x86_64/heap/heap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void heap_init(void) {
2424

2525
// 内存申请
2626
ptr_t kmalloc(size_t byte) {
27-
ptr_t addr = 0;
27+
ptr_t addr = (ptr_t)NULL;
2828
addr = heap_manager->heap_manage_malloc(byte);
2929
return addr;
3030
}

src/arch/x86_64/task/task.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ ListEntry * runnable_list = NULL;
2828
// 等待进程链表
2929
ListEntry * wait_list = NULL;
3030

31-
// 申请栈空间
32-
static inline ptr_t alloc_stack(void);
33-
static inline ptr_t alloc_stack(void) {
34-
35-
return 0;
36-
}
37-
3831
// 返回一个空的任务控制块
3932
static task_pcb_t * alloc_task_pcb(void) {
4033
cpu_cli();

src/include/mem/pmm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ extern "C" {
1515
#include "e820.h"
1616
#include "multiboot2.h"
1717

18-
// 32KB
19-
#define KERNEL_STACK_SIZE (0x8000UL)
18+
// 8KB
19+
#define KERNEL_STACK_SIZE (0x2000UL)
2020
#define KERNEL_STACK_PAGES (KERNEL_STACK_SIZE / PMM_PAGE_SIZE)
2121
#define KERNEL_STACK_BOTTOM (0xC0000000UL)
2222
#define KERNEL_STACK_TOP (KERNEL_STACK_BOTTOM - KERNEL_STACK_SIZE)

src/kernel.bin

-548 Bytes
Binary file not shown.

src/kernel/mem/slab.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,12 @@ void init(ptr_t addr_start) {
186186
return;
187187
}
188188

189-
static inline void slab_split(list_entry_t * list, size_t byte);
189+
static inline list_entry_t * slab_split(list_entry_t * list, size_t byte);
190190
static inline void slab_merge(list_entry_t * list);
191191

192192
// 切分内存块,len 为调用者申请的大小,不包括头大小
193-
void slab_split(list_entry_t * entry, size_t len) {
193+
// 返回分割出来的管理头地址
194+
list_entry_t * slab_split(list_entry_t * entry, size_t len) {
194195
// 如果剩余内存大于内存头的长度+设定的最小长度
195196
if( (list_slab_block(entry)->len - len > sizeof(list_entry_t) + SLAB_MIN) ) {
196197
// 添加新的链表项,位于旧表项开始地址+旧表项长度
@@ -204,8 +205,9 @@ void slab_split(list_entry_t * entry, size_t len) {
204205
list_add_after(entry, new_entry);
205206
// 重新设置旧链表信息
206207
list_slab_block(entry)->len = len;
208+
return new_entry;
207209
}
208-
return;
210+
return (list_entry_t *)NULL;
209211
}
210212

211213
// 合并内存块

0 commit comments

Comments
 (0)