⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syscall.c

📁 jos lab3代码
💻 C
字号:
// System call stubs.#include <inc/syscall.h>#include <inc/lib.h>static inline int32_tsyscall(int num, int check, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5){	int32_t ret;	// Generic system call: pass system call number in AX,	// up to five parameters in DX, CX, BX, DI, SI.	// Interrupt kernel with T_SYSCALL.	//	// The "volatile" tells the assembler not to optimize	// this instruction away just because we don't use the	// return value.	// 	// The last clause tells the assembler that this can	// potentially change the condition codes and arbitrary	// memory locations.	asm volatile("int %1\n"		: "=a" (ret)		: "i" (T_SYSCALL),		  "a" (num),		  "d" (a1),		  "c" (a2),		  "b" (a3),		  "D" (a4),		  "S" (a5)		: "cc", "memory");		if(check && ret > 0)		panic("syscall %d returned %d (> 0)", num, ret);	return ret;}voidsys_cputs(const char *s, size_t len){	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);}intsys_cgetc(void){	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);}intsys_env_destroy(envid_t envid){	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);}envid_tsys_getenvid(void){	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -