mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-22 15:23:23 +00:00
new: vma反向映射
This commit is contained in:
20
kernel/arch/x86_64/current.h
Normal file
20
kernel/arch/x86_64/current.h
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include <common/glib.h>
|
||||
|
||||
#pragma GCC push_options
|
||||
#pragma GCC optimize("O0")
|
||||
struct process_control_block;
|
||||
// 获取当前的pcb
|
||||
static __always_inline struct process_control_block *get_current_pcb()
|
||||
{
|
||||
struct process_control_block *current = NULL;
|
||||
// 利用了当前pcb和栈空间总大小为32k大小对齐,将rsp低15位清空,即可获得pcb的起始地址
|
||||
barrier();
|
||||
__asm__ __volatile__("andq %%rsp, %0 \n\t"
|
||||
: "=r"(current)
|
||||
: "0"(~32767UL));
|
||||
barrier();
|
||||
return current;
|
||||
};
|
||||
#define current_pcb get_current_pcb()
|
||||
#pragma GCC pop_options
|
Reference in New Issue
Block a user