使得DragonOS kernel 能为riscv64编译通过(尚未能启动) (#457)

* 使得DragonOS kernel 能为riscv64编译通过(尚未能启动)

* 修正了系统调用号声明不正确的问题,同时添加了编译配置文档
This commit is contained in:
LoGin
2023-11-25 12:07:39 +08:00
committed by GitHub
parent a1fd1cf1cb
commit 4fda81ce81
112 changed files with 2587 additions and 615 deletions

View File

@ -3,11 +3,6 @@
#ifndef __ASM__
#define __ASM__
// 符号名
#define SYMBOL_NAME(X) X
// 符号名字符串

View File

@ -9,6 +9,8 @@
*
*/
#pragma once
#if ARCH(I386) || ARCH(X86_64)
#include <arch/x86_64/include/asm/cmpxchg.h>
#define atomic_read(atomic) ((atomic)->value) // 读取原子变量
@ -105,3 +107,4 @@ inline long atomic_cmpxchg(atomic_t *ato, long oldval, long newval)
bool success = arch_try_cmpxchg(&ato->value, &oldval, newval);
return success ? oldval : newval;
}
#endif

View File

@ -1,6 +1,10 @@
#pragma once
#if ARCH(I386) || ARCH(X86_64)
#pragma GCC push_options
#pragma GCC optimize("O1")
#include <common/errno.h>
#include <common/spinlock.h>
@ -170,4 +174,6 @@ bool ida_count(struct ida *ida_p, int id);
void ida_remove(struct ida *ida_p, int id);
void ida_destroy(struct ida *ida_p);
#pragma GCC pop_options
#pragma GCC pop_options
#endif

View File

@ -1,10 +1,13 @@
#pragma once
#include "stddef.h"
#include <arch/arch.h>
#if ARCH(I386) || ARCH(X86_64)
#if ARCH(I386) || ARCH(X86_64)
#include <arch/x86_64/math/bitcount.h>
#else
#error Arch not supported.
#endif
#endif
int64_t pow(int64_t x, int y);

View File

@ -8,4 +8,12 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; // Signed integer type of the result of subt
#ifndef __always_inline
#define __always_inline __inline__
#endif
#endif
// 定义类型的缩写
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ul;
typedef unsigned long long int ull;
typedef long long int ll;

View File

@ -40,7 +40,7 @@ long strnlen(const char *src, unsigned long maxlen);
int strcmp(const char *FirstPart, const char *SecondPart);
char *strncpy(char *dst, const char *src, long count);
char *strncpy(char *restrict d, const char *restrict s, size_t n);
long strncpy_from_user(char *dst, const char *src, unsigned long size);
@ -52,31 +52,6 @@ long strncpy_from_user(char *dst, const char *src, unsigned long size);
*/
long strnlen_user(const char *src, unsigned long maxlen);
/**
* @brief 逐字节比较指定内存区域的值并返回s1、s2的第一个不相等的字节i处的差值s1[i]-s2[i])。
* 若两块内存区域的内容相同则返回0
*
* @param s1 内存区域1
* @param s2 内存区域2
* @param len 要比较的内存区域长度
* @return int s1、s2的第一个不相等的字节i处的差值s1[i]-s2[i])。若两块内存区域的内容相同则返回0
*/
static inline int memcmp(const void *s1, const void *s2, size_t len)
{
int diff;
asm("cld \n\t" // 复位DF确保s1、s2指针是自增的
"repz; cmpsb\n\t" CC_SET(nz)
: CC_OUT(nz)(diff), "+D"(s1), "+S"(s2)
: "c"(len)
: "memory");
if (diff)
diff = *(const unsigned char *)(s1 - 1) - *(const unsigned char *)(s2 - 1);
return diff;
}
/**
* @brief 拼接两个字符串将src接到dest末尾
*