new: mstat()函数,查询内存信息

This commit is contained in:
fslongjin
2022-08-06 23:31:25 +08:00
parent fdd5d3cf66
commit fb51b0dd6f
8 changed files with 270 additions and 7 deletions

View File

@ -1,7 +1,18 @@
#include "stat.h"
#include<libsystem/syscall.h>
#include <libsystem/syscall.h>
int mkdir(const char *path, mode_t mode)
{
return syscall_invoke(SYS_MKDIR, (uint64_t)path, (uint64_t)mode, 0,0,0,0,0,0);
return syscall_invoke(SYS_MKDIR, (uint64_t)path, (uint64_t)mode, 0, 0, 0, 0, 0, 0);
}
/**
* @brief 获取系统的内存信息
*
* @param stat 传入的内存信息结构体
* @return int 错误码
*/
int mstat(struct mstat_t *stat)
{
return syscall_invoke(SYS_MSTAT, (uint64_t)stat, 0, 0, 0, 0, 0, 0, 0);
}

View File

@ -1,4 +1,27 @@
#pragma once
#include <libc/sys/types.h>
int mkdir(const char *path, mode_t mode);
/**
* @brief 系统内存信息结构体(单位:字节)
*
*/
struct mstat_t
{
uint64_t total; // 计算机的总内存数量大小
uint64_t used; // 已使用的内存大小
uint64_t free; // 空闲物理页所占的内存大小
uint64_t shared; // 共享的内存大小
uint64_t cache_used; // 位于slab缓冲区中的已使用的内存大小
uint64_t cache_free; // 位于slab缓冲区中的空闲的内存大小
uint64_t available; // 系统总空闲内存大小包括kmalloc缓冲区
};
int mkdir(const char *path, mode_t mode);
/**
* @brief 获取系统的内存信息
*
* @param stat 传入的内存信息结构体
* @return int 错误码
*/
int mstat(struct mstat_t* stat);

View File

@ -24,6 +24,9 @@
#define SYS_MKDIR 17 // 创建文件夹
#define SYS_NANOSLEEP 18 // 纳秒级休眠
#define SYS_CLOCK 19 // 获取当前cpu时间
#define SYS_PIPE 20
#define SYS_MSTAT 21 // 获取系统的内存状态信息
/**
* @brief 用户态系统调用函数