结合前几节的内容,实现系统调用malloc 和 free。
根据系统调用的步骤:
(1)封装函数malloc & free
(2)在函数中调用宏 _syscall1(),在宏中就执行int 0x80 中断进入内核态。
(3)在syscall_table 数组中添加函数sys_malloc 和 函数 sys_free. 这样在中断处理子程序中就会跳转到 sys_malloc 和 sys_free 来执行内存的分配与释放。
在syscall.c中
void* malloc(uint32_t size)
{
return (void*)_syscall1(SYS_MALLOC, size