This commit is contained in:
fslongjin 2022-05-11 20:42:30 +08:00
parent 77d4854db7
commit edb21695ae
9 changed files with 117 additions and 10 deletions

View File

@ -6,7 +6,7 @@
"${workspaceFolder}/**"
],
"defines": [
"x86_64",
"__x86_64__",
"DEBUG"
],
"compilerPath": "/usr/bin/gcc",

View File

@ -94,7 +94,8 @@
"fcntl.h": "c",
"types.h": "c",
"string.h": "c",
"math.h": "c"
"math.h": "c",
"ipi.h": "c"
},
"C_Cpp.errorSquiggles": "Enabled",
"esbonio.sphinx.confDir": ""

View File

@ -3,7 +3,7 @@ SUBDIRS = kernel user
export ARCH=x86_64
export ARCH=__x86_64__
export ROOT_PATH=$(shell pwd)
export DEBUG=DEBUG

View File

@ -89,7 +89,7 @@ VFS.o: filesystem/VFS/VFS.c
gcc $(CFLAGS) -c filesystem/VFS/VFS.c -o filesystem/VFS/VFS.o
# IPI的代码
ifeq ($(ARCH), x86_64)
ifeq ($(ARCH), __x86_64__)
OBJ_LIST += ipi.o
LD_LIST += arch/x86_64/x86_64_ipi.o
ipi.o: arch/x86_64/x86_64_ipi.c

12
kernel/arch/arch.h Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#define ARCH(arch) (defined(AK_ARCH_##arch) && AK_ARCH_##arch)
#ifdef __i386__
# define AK_ARCH_I386 1
#endif
#ifdef __x86_64__
# define AK_ARCH_X86_64 1
#endif

View File

@ -8,8 +8,10 @@
//引入对bool类型的支持
#include <stdbool.h>
#include <stdint.h>
#include <common/miniLibc/stddef.h>
#include <arch/arch.h>
#define NULL 0
#define sti() __asm__ __volatile__("sti\n\t" :: \
: "memory") //开启外部中断

View File

@ -0,0 +1,7 @@
#pragma once
#include "./sys/types.h"
#define NULL 0
typedef __PTRDIFF_TYPE__ ptrdiff_t; // Signed integer type of the result of subtracting two pointers.

View File

@ -0,0 +1,84 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef uint32_t uid_t;
typedef uint32_t gid_t;
typedef long long ssize_t;
typedef int __pid_t;
#define pid_t __pid_t
typedef __SIZE_TYPE__ size_t;
typedef char *caddr_t;
typedef int id_t;
typedef uint64_t ino_t;
typedef int64_t off_t;
typedef uint32_t blkcnt_t;
typedef uint32_t blksize_t;
typedef uint32_t dev_t;
typedef uint16_t mode_t;
typedef uint32_t nlink_t;
typedef int64_t time_t;
typedef uint32_t useconds_t;
typedef int32_t suseconds_t;
typedef uint32_t clock_t;
typedef uint64_t fsblkcnt_t;
typedef uint64_t fsfilcnt_t;
#define __socklen_t_defined
#define __socklen_t uint32_t
typedef __socklen_t socklen_t;
struct utimbuf
{
time_t actime;
time_t modtime;
};
typedef int pthread_t;
typedef int pthread_key_t;
typedef uint32_t pthread_once_t;
typedef struct __pthread_mutex_t
{
uint32_t lock;
pthread_t owner;
int level;
int type;
} pthread_mutex_t;
typedef void *pthread_attr_t;
typedef struct __pthread_mutexattr_t
{
int type;
} pthread_mutexattr_t;
typedef struct __pthread_cond_t
{
pthread_mutex_t *mutex;
uint32_t value;
int clockid; // clockid_t
} pthread_cond_t;
typedef uint64_t pthread_rwlock_t;
typedef void *pthread_rwlockattr_t;
typedef struct __pthread_spinlock_t
{
int m_lock;
} pthread_spinlock_t;
typedef struct __pthread_condattr_t
{
int clockid; // clockid_t
} pthread_condattr_t;

View File

@ -1,6 +1,7 @@
#pragma once
#ifdef x86_64
#include <arch/arch.h>
#if ARCH(I386) || ARCH(X86_64)
#include <arch/x86_64/x86_64_ipi.h>
#else
#error "error type of arch!"
@ -24,15 +25,15 @@ extern void ipi_send_IPI(uint32_t dest_mode, uint32_t deliver_status, uint32_t l
/**
* @brief ipi中断处理注册函数
*
*
* @param irq_num
* @param arg
* @param handler
* @param param
* @param controller NULL
* @param controller NULL
* @param irq_name ipi中断名
* @return int 0
*/
extern int ipi_regiserIPI(uint64_t irq_num, void *arg,
void (*handler)(uint64_t irq_num, uint64_t param, struct pt_regs *regs),
uint64_t param, hardware_intr_controller *controller, char *irq_name);
void (*handler)(uint64_t irq_num, uint64_t param, struct pt_regs *regs),
uint64_t param, hardware_intr_controller *controller, char *irq_name);