repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
zhusonghe/PaddleClas-1
deploy/cpp/include/cls.h
// Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required...
zhusonghe/PaddleClas-1
deploy/cpp_shitu/include/nms.h
// Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required...
zhusonghe/PaddleClas-1
deploy/lite_shitu/include/recognition.h
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required...
zhusonghe/PaddleClas-1
deploy/lite_shitu/include/config_parser.h
<filename>deploy/lite_shitu/include/config_parser.h // Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www...
zhusonghe/PaddleClas-1
deploy/cpp_shitu/include/object_detector.h
// Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless requir...
zhusonghe/PaddleClas-1
deploy/cpp_shitu/include/preprocess_op_det.h
<gh_stars>100-1000 // Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 ...
zhusonghe/PaddleClas-1
deploy/lite_shitu/include/utils.h
<filename>deploy/lite_shitu/include/utils.h // Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache....
zhusonghe/PaddleClas-1
deploy/cpp_shitu/include/feature_extracter.h
<filename>deploy/cpp_shitu/include/feature_extracter.h // Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://ww...
NightfallDM/xbook2
library/xlibc/stdlib/qsort.c
<gh_stars>0 #include <stdlib.h> #include <string.h> void swap(char * a, char * b, size_t width) { char tmp; while (width--) { tmp = *a; *a++ = *b; *b++ = tmp; } } char * partition(char * lo, char * hi, int (*comp)(const void *, const void *), size_t width) { char * i = lo; c...
NightfallDM/xbook2
library/xlibc/include/sys/ioctl.h
<filename>library/xlibc/include/sys/ioctl.h #ifndef _SYS_IOCTL_H #define _SYS_IOCTL_H /* 设备控制码: 0~15位:命令(0-0x7FFF系统保留,0x8000-0xffff用户自定义) 16~31位:设备类型 */ #ifndef DEVCTL_CODE #define DEVCTL_CODE(type, cmd) \ ((unsigned int) ((((type) & 0xffff) << 16) | ((cmd) & 0xffff))) #endif /* 设备标志 */ #define DEV_NOWAIT ...
NightfallDM/xbook2
library/xlibc/include/sys/spinlock.h
<gh_stars>0 #ifndef _SYS_SPINLOCK_H #define _SYS_SPINLOCK_H #include <arch/atomic.h> typedef struct { volatile int lock; } spinlock_t; /* 默认初始化为未初始化的自旋锁 */ #define SPIN_LOCK_INIT() \ {.lock = 0} int spin_lock_init(spinlock_t *lock); int spin_lock(spinlock_t *lock); int spin_trylock(spinlock_t *lock); int s...
NightfallDM/xbook2
library/xlibc/include/sys/srvcall.h
<reponame>NightfallDM/xbook2 #ifndef _SYS_SRVCALL_H #define _SYS_SRVCALL_H /** * 系统调用是用户态陷入内核,让内核帮忙执行一些内容。 * 服务调用是用户态转移到用户态,让服务进程帮忙执行一些内容。 * srvcall, 传入参数,然后先陷入内核,然后寻找到对应的服务进程。 * 查看服务进程的状态,如果可转移,那么就直接转移,不然,就等待。 * * 服务进程,先通过系统调用,进入到可服务状态,等待其它进程跳转服务。 * 先查看就绪队列,如果有就从里面挑选一个出来,并执行。然后继续陷入 * 内核挑选,直到就绪队列为空,然后就进入阻塞等待状...
NightfallDM/xbook2
src/include/xbook/resource.h
#ifndef _XBOOK_RESOURCE_H #define _XBOOK_RESOURCE_H #include <types.h> #include <stddef.h> /* 每个进程可持有的资源数量 */ #define RES_NR 64 #define RES_MASK 0x00ffffff /* 资源本身的标志,0~15位 */ #define RES_LOCAL_MASK 0x0000ffff /* 资源管理类型的标志,24~31是主类型 */ #define RES_MASTER_MASK 0xff000000 /* 资源管理类型的标志,16~23位是从类型 ...
NightfallDM/xbook2
library/xlibc/include/xcons.h
#ifndef _XLIBC_XCONSOLE_H #define _XLIBC_XCONSOLE_H #define XCONS_KMOD_SHIFT_L 0x01 #define XCONS_KMOD_SHIFT_R 0x02 #define XCONS_KMOD_SHIFT (XCONS_KMOD_SHIFT_L | XCONS_KMOD_SHIFT_R) #define XCONS_KMOD_CTRL_L 0x04 #define XCONS_KMOD_CTRL_R 0x08 #define XCONS_KMOD_CTRL (XCONS_KMOD_CTRL_L | XCON...
NightfallDM/xbook2
src/include/sys/res.h
<reponame>NightfallDM/xbook2<gh_stars>0 #ifndef _SYS_RES_H #define _SYS_RES_H /* 资源类型 */ #define RES_DEV 0x1000000 /* device resource */ #define RES_IPC 0x2000000 /* ipc resource */ /* 资源的控制命令 */ #define RES_REDIR 1 #define DEVICE_NAME_LEN 32 /* 设备项 */ typedef struc...
NightfallDM/xbook2
library/xlibc/syslib/time.c
<filename>library/xlibc/syslib/time.c #include <sys/time.h> #include <sys/syscall.h> #include <time.h> #include <errno.h> /** * alarm - 设置一个闹钟 * @second: 闹钟产生的时间 * * @return: return left second before alarm */ unsigned long alarm(unsigned long second) { return syscall1(unsigned long , SYS_ALARM, second); } /...
NightfallDM/xbook2
src/include/sys/srvcall.h
<gh_stars>0 #ifndef _SYS_SRVCALL_H #define _SYS_SRVCALL_H #define SRVIO_SERVICE 0 /* 流向服务 */ #define SRVIO_USER 1 /* 流向用户 */ #define SRVIO_BOTH 3 /* 双向 */ #define SRVARG_NR 8 typedef struct _srvarg { unsigned long data[SRVARG_NR]; /* 参数的值 */ long size[SRVARG_NR]; ...
NightfallDM/xbook2
src/vmm/dma.c
<reponame>NightfallDM/xbook2 #include <arch/page.h> #include <arch/ioremap.h> #include <xbook/vmarea.h> #include <xbook/dma.h> #include <math.h> int alloc_dma_buffer(struct dma_region *d) { /* 参数检测 */ if (!d->p.size) return -1; int npages = DIV_ROUND_UP(d->p.size, PAGE_SIZE); d->p.address = ...
NightfallDM/xbook2
src/kernel/alarm.c
#include <xbook/alarm.h> #include <xbook/task.h> #include <xbook/clock.h> #include <xbook/debug.h> #include <xbook/trigger.h> #define DEBUG_LOCAL 0 unsigned long sys_alarm(unsigned long second) { task_t *cur = current_task; /* 需要返回上次剩余的秒数 */ unsigned long old_second = cur->alarm.second; ...
NightfallDM/xbook2
src/include/types.h
<filename>src/include/types.h #ifndef _XBOOK_TYPES_H #define _XBOOK_TYPES_H #include <xbook/config.h> typedef long pid_t; typedef unsigned long flags_t; typedef unsigned long register_t; //寄存器 typedef unsigned long off_t; //偏移类型的变量 typedef unsigned long sector_t; typedef unsigned int mode_t; t...
NightfallDM/xbook2
library/pthread/pthread_spinlock.c
<gh_stars>1-10 #include <pthread.h> #include <arch/xchg.h> #include <sys/proc.h> #include <stdio.h> #include <errno.h> /* 自选一定次数后,才进行yeild */ #define __SPIN_COUNT 10 int pthread_spin_init(pthread_spinlock_t *lock, int pshared) { if (!lock) return EINVAL; //lock->count = 0; atomic_set(&lock->cou...
NightfallDM/xbook2
user/bosh/cmd.c
<reponame>NightfallDM/xbook2 #include <string.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <ctype.h> #include <math.h> #include <sys/ipc.h> #include <sys/res.h> #include <sys/wait.h> #include <sys/proc.h> #include <sys/sys.h> #include <sys/vmm.h> #include <sys/time.h> #include <arch/const.h> #...
NightfallDM/xbook2
src/gui/lowlevel/keyboard.c
<gh_stars>0 #include <string.h> #include <stdio.h> #include <xbook/driver.h> #include <sys/ioctl.h> #include <xbook/kmalloc.h> #include <xbook/vmarea.h> /// 程序本地头文件 #include <gui/keyboard.h> #include <gui/event.h> #include <sys/input.h> #include <gui/console/console.h> #ifndef GUI_KEYBOARD_DEVICE_NAME #define GUI...
NightfallDM/xbook2
src/arch/x86/include/arch/types.h
#ifndef _TYPES_H_ #define _TYPES_H_ #define MACHINE_WIDTH 32 #define TRUE 1 #define FALSE 0 typedef unsigned char bool_t; typedef unsigned short uint16_t; typedef short int16_t; typedef char int8_t; typedef unsigned char uint8_t; typedef unsigned int uint32_t; typedef int uint32_t; struct Page_e { uint32_t attr: 1...
NightfallDM/xbook2
library/xlibc/stdio/asprintf.c
<reponame>NightfallDM/xbook2<gh_stars>1-10 /* * libc/stdio/asprintf.c */ #include <stdio.h> int asprintf(char ** s, const char * fmt, ...) { va_list ap; int ret; va_start(ap, fmt); ret = vasprintf(s, fmt, ap); va_end(ap); return ret; }
NightfallDM/xbook2
src/arch/x86/mach-i386/tss.c
#include <arch/tss.h> #include <arch/segment.h> #include <arch/registers.h> #include <arch/pmem.h> #include <string.h> #include <xbook/task.h> /* tss对象 */ tss_t tss; tss_t *get_tss() { return &tss; } void update_tss_info(unsigned long task_addr) { // 更新tss.esp0的值为任务的内核栈顶 tss.esp0 = (unsigned long)(task_addr + TAS...
NightfallDM/xbook2
src/arch/x86/include/arch/instruction.h
#ifndef _ARCH_INSTRUCTION_H #define _ARCH_INSTRUCTION_H void __invlpg_asm(unsigned int addr); #define __invlpg_inline(vaddr) asm volatile ("invlpg %0"::"m" (vaddr):"memory") /* __invlpg_asm or __invlpg_inline */ #define flush_tbl(vaddr) __invlpg_inline(vaddr) void __cpuid(unsigned int id_eax, unsigned int *eax, ...
NightfallDM/xbook2
src/arch/x86/mach-i386/mp.c
/* * MultiProcessor support for xbook2 * Search memory for MP description structures. * */ // reference to xv6-public,thanks to them. :-) #include<arch/types.h> #include<arch/mp.h> void mpinit(void){ }
NightfallDM/xbook2
src/gui/graph/rect.c
#include <gui/screen.h> #include <gui/rect.h> /* 封装screen */ void gui_draw_rect_fill(int x, int y, int width, int height, GUI_COLOR color) { gui_screen.output_rect_fill(x, y, x + width - 1, y + height - 1, color); } /* 封装screen */ void gui_draw_rect(int x, int y, int width, int height, GUI_COLOR color) { /* l...
NightfallDM/xbook2
library/xlibc/math/fabs.c
/* File: fabs.c Contains: For abs(x) Written by: GUI Copyright: (C) 2017-2020 by GuEe Studio for Book OS. All rights reserved. */ #include <math.h> M_FLOAT fabs(M_FLOAT x) { return (x < 0 ? -x : x); }
NightfallDM/xbook2
library/xlibc/math/sqrt.c
/* File: sqrt.c Contains: For sqrt(x) Written by: GUI Copyright: (C) 2017-2020 by GuEe Studio for Book OS. All rights reserved. */ #include <math.h> M_FLOAT sqrt(float x) { /* It's not important */ if (fabs(x) < EPSILON) return (0.0); float x2 = x * 0.5F, y = x; lo...
NightfallDM/xbook2
src/include/xbook/sem.h
#ifndef _XBOOK_SEM_H #define _XBOOK_SEM_H /* 用户可以使用的信号量 */ #include "semaphore.h" /* 最多有多少个信号量 */ #define SEM_MAX_NR 128 /* 信号量的最大值, int 型数据最大值 */ #define SEM_MAX_VALUE (‭2147483647‬) #define SEM_NAME_LEN 24 /* 信号量结构 */ typedef struct { unsigned short id; /* 信号量id */ ...
NightfallDM/xbook2
library/xlibc/include/sys/types.h
<gh_stars>0 #ifndef _SYS_TYPES_H #define _SYS_TYPES_H #include <stddef.h> #include <stdint.h> #include <types.h> #define DIR_NAME_LEN 256 #define DE_RDONLY 0x01 /* read only */ #define DE_HIDDEN 0x02 /* hidden */ #define DE_SYSTEM 0x04 /* system */ #define DE_DIR 0x10 /* dir...
NightfallDM/xbook2
src/fs/fsal/fsalif.c
#include <fsal/fsal.h> #include <fsal/dir.h> #include <fsal/fstype.h> #include <stddef.h> #include <xbook/diskman.h> #include <xbook/debug.h> static int __open(void *path, int flags) { if (path == NULL) return -1; fsal_path_t *fpath = fsal_path_find(path, 1); if (fpath == NULL) { prin...
NightfallDM/xbook2
src/include/gui/console/console.h
<gh_stars>0 #ifndef __TERMINAL_CONSOLE_H__ #define __TERMINAL_CONSOLE_H__ #include <stddef.h> #include <gui/color.h> #include <xbook/fifoio.h> /* 80*25*20 = 10kb */ #define CON_FRAME_NR 20 #define CON_CHAR_WIDTH 8 #define CON_CHAR_HEIGHT 16 #define CON_CLOUMNS 80 #define CON_ROWS 25 #define CON_BUF...
NightfallDM/xbook2
user/tests/trig_test.c
<reponame>NightfallDM/xbook2<filename>user/tests/trig_test.c<gh_stars>0 #include "test.h" #include <sys/trigger.h> void trig_handler(int trig) { printf("trig: %d handled!\n", trig); } void alarm_handler(int trig) { printf("alarm: handled\n"); } int trig_test(int argc, char *argv[]) { printf("----trig tes...
NightfallDM/xbook2
library/xlibc/stdio/rename.c
<filename>library/xlibc/stdio/rename.c /* * libc/stdio/rename.c */ #include <stdio.h> #include <unistd.h> int rename(const char * old, const char * new) { return _rename(old, new); }
NightfallDM/xbook2
library/xlibc/math/acos.c
<reponame>NightfallDM/xbook2 /* File: acos.c Contains: For arccos(x) Written by: GUI Copyright: (C) 2017-2020 by GuEe Studio for Book OS. All rights reserved. */ #include <math.h> M_FLOAT acos(M_FLOAT x) { return atan2(sqrt(1.0 - x * x), x); }
NightfallDM/xbook2
src/arch/x86/mach-i386/time.c
#include <arch/time.h> void __udelay(int usec) { int i, j; for (i = 0; i < 10 * usec; i++); for (j = 0; j < 100; j++); }
NightfallDM/xbook2
library/xlibc/include/sys/kfile.h
<filename>library/xlibc/include/sys/kfile.h #ifndef _SYS_KFILE_H #define _SYS_KFILE_H typedef struct { unsigned char *file; unsigned long size; } kfile_t; #endif /* _SYS_KFILE_H */
NightfallDM/xbook2
library/xlibc/include/time.h
#ifndef __XLIBC_TIME_H__ #define __XLIBC_TIME_H__ #ifdef __cplusplus extern "C" { #endif #include <stdint.h> #include <types.h> #include <sys/time.h> struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long __tm_gmtoff; const char...
NightfallDM/xbook2
src/include/xbook/kmalloc.h
<reponame>NightfallDM/xbook2 #ifndef _XBOOK_KMALLOC_H #define _XBOOK_KMALLOC_H #include "memcache.h" #endif /* _XBOOK_KMALLOC_H */
NightfallDM/xbook2
library/xlibc/include/arch/xchg.h
#ifndef _LIB_ARCH_XCHG_H #define _LIB_ARCH_XCHG_H #include <arch/config.h> #define test_and_set __test_and_set #endif /* _LIB_ARCH_XCHG_H */
NightfallDM/xbook2
library/xlibc/math/round.c
/* File: round.c Contains: For rounding Written by: GUI Copyright: (C) 2017-2020 by GuEe Studio for Book OS. All rights reserved. */ #include <math.h> M_FLOAT round(M_FLOAT x) { if (x > 0) return (int)(x + 0.5); return (int)(x - 0.5); }
NightfallDM/xbook2
src/fs/fs.c
<reponame>NightfallDM/xbook2<gh_stars>0 #include <xbook/fs.h> #include <xbook/diskman.h> #include <xbook/debug.h> #include <fsal/fsal.h> #include <fsal/fstype.h> #include <stddef.h> #include <unistd.h> #include <dirent.h> int init_fs() { if (init_disk_driver() < 0) panic("[fs]: init disk driver failed!\n")...
NightfallDM/xbook2
library/xlibc/include/exit.h
<reponame>NightfallDM/xbook2<filename>library/xlibc/include/exit.h #ifndef __XLIBC_EXIT_H__ #define __XLIBC_EXIT_H__ #ifdef __cplusplus extern "C" { #endif #include <sys/proc.h> enum { EXIT_SUCCESS = 0, EXIT_FAILURE = 1, }; void abort(void); #define exit _exit #ifdef __cplusplus } #endif #endif /* __XLIBC_EX...
NightfallDM/xbook2
library/xlibc/include/setjmp.h
<gh_stars>0 #ifndef _XLIBC_SETJMP_H #define _XLIBC_SETJMP_H /*my_setjmp.h*/ /* * c程序不允许函数的嵌套定义。 * 所以除了返回调用哪个函数的表达式外,c语言没有提供其他将控制权转移到一个函数之外的简单方法。 * c语言使用库函数实现非本地控制转移。 * jmp_buf类型,标量数据对象类型。 * longjmp函数,用来实现非本地控制转移。 * setjmp宏,把当前调用的上下文信息存储到一个jmp_buf类型的数据对象中,并在你想把控制权传递给相应的 * longjmp调用的地方做标记。 * 两个潜在危险:包含setjmp宏达表达式;...
NightfallDM/xbook2
src/include/xbook/vmm.h
<reponame>NightfallDM/xbook2 #ifndef _XBOOK_VMM_H #define _XBOOK_VMM_H #include <arch/page.h> #define USER_VMM_SIZE PAGE_OFFSET #define USER_STACK_TOP USER_VMM_SIZE #define VMM_UNMAPPED_BASE (USER_VMM_SIZE / 2) /* 进程空间虚拟内存管理 */ typedef struct vmm { void *page_storage; ...
NightfallDM/xbook2
src/driver/disk/ahci.c
#include <xbook/debug.h> #include <xbook/kernel.h> #include <const.h> #include <math.h> #include <xbook/softirq.h> #include <xbook/vine.h> #include <xbook/driver.h> #include <string.h> #include <xbook/clock.h> #include <arch/io.h> #include <arch/interrupt.h> #include <arch/cpu.h> #include <arch/ioremap.h> #include <arc...
NightfallDM/xbook2
src/include/xbook/ktime.h
#ifndef _XBOOK_KTIME_H #define _XBOOK_KTIME_H #include <arch/time.h> #include <sys/ktime.h> #include <sys/time.h> extern ktime_t ktime; void update_ktime(); void print_ktime(); void sys_get_ktime(ktime_t *time); void init_ktime(); static inline unsigned long ktime2uint32() { unsigned short date...
NightfallDM/xbook2
library/xlibc/math/ldexp.c
<gh_stars>0 /* File: ldexp.c Contains: For x * 2^exp Written by: GUI Copyright: (C) 2017-2020 by GuEe Studio for Book OS. All rights reserved. */ #include <math.h> M_FLOAT ldexp(M_FLOAT x, int exp) { return (x * (double)pow(2.0, exp)); }
NightfallDM/xbook2
src/ipc/msgqueue.c
<gh_stars>0 #include <xbook/msgqueue.h> #include <xbook/debug.h> #include <string.h> #include <math.h> #include <sys/ipc.h> /* debug msgq : 1 enable, 0 disable */ #define DEBUG_MSGQ 0 /* 消息队列表 */ msg_queue_t *msg_queue_table; /* 保护消息队列的分配与释放 */ DEFINE_SEMAPHORE(msg_queue_mutex, 1); /** * msg_queue...
NightfallDM/xbook2
src/include/xbook/trigger.h
#ifndef _XBOOK_TRIGGER_H #define _XBOOK_TRIGGER_H #include <types.h> #include <sys/trigger.h> #include <arch/interrupt.h> #include <xbook/spinlock.h> #define TRIG_LEFT (1 << 0) /* 有剩余的触发器没处理 */ #define TRIG_CATCHED (1 << 1) /* 触发器被捕捉,并且已经处理了 */ typedef struct { trigset_...
NightfallDM/xbook2
src/include/xbook/elf32.h
<reponame>NightfallDM/xbook2 #ifndef _XBOOK_ELF32_H #define _XBOOK_ELF32_H #include <stdint.h> /* 自定义的elf类型 */ typedef uint32_t Elf32_Word, Elf32_Addr, Elf32_Off; typedef uint16_t Elf32_Half; /* 32位elf头 */ struct Elf32_Ehdr { unsigned char e_ident[16]; Elf32_Half e_type; Elf32_Half e_ma...
NightfallDM/xbook2
src/include/assert.h
<gh_stars>0 #ifndef _XBOOK_ASEERT_H #define _XBOOK_ASEERT_H //断言 #define CONFIG_ASSERT 1 #if CONFIG_ASSERT == 1 void assertion_failure(char *exp, char *file, char *baseFile, int line); #define ASSERT(exp) if (exp) ; \ else assertion_failure(#exp, __FILE__, __BASE_FILE__, __LINE__) #else #define ASSERT(exp) #...
NightfallDM/xbook2
library/xlibc/arpa/inet.c
<filename>library/xlibc/arpa/inet.c<gh_stars>0 #include <arpa/inet.h> // 短整型大小端互换 #define endian_swap16(a) \ ((((uint16_t)(a) & 0xff00) >> 8) | \ (((uint16_t)(a) & 0x00ff) << 8)) // 长整型大小端互换 #define endian_swap32(a) \ ((((uint32_t)(a) & 0xff000000) >> 24) | \ (((uint32_t)(a) & 0x00ff0000) >> 8...
NightfallDM/xbook2
src/include/xbook/pci.h
#ifndef _ARCH_PCI_H #define _ARCH_PCI_H /* 【简介】 PCI是什么?PCI是Peripheral Component Interconnect(外设部件互连标准)的缩写, 它是目前个人电脑中使用最为广泛的接口,几乎所有的主板产品上都带有这种插槽。 PCI有三个相互独立的物理地址空间:设备存储器地址空间、I/O地址空间和配置空间。 配置空间是PCI所特有的一个物理空间。由于PCI支持设备即插即用,所以PCI设备不占 用固定的内存地址空间或I/O地址空间,而是由操作系统决定其映射的基址。 PCI总线规范定义的配置空间总长度为256个字节,配置信息按一定的顺序和大小依次存放。 前64个...
NightfallDM/xbook2
src/include/xbook/netcard.h
#ifndef _XBOOK_NETCARD_H #define _XBOOK_NETCARD_H #include <list.h> #include <types.h> #include <xbook/driver.h> /* 磁盘驱动器 */ typedef struct { list_t list; /* 信息链表 */ int solt; /* 插槽位置 */ int handle; /* 资源句柄 */ devent_t devent; /* 设备项 */ char virname[DEVICE_NAME_LEN]; ...
NightfallDM/xbook2
src/gui/console/clipboard.c
#include <string.h> #include <stdio.h> #include <unistd.h> #include <stddef.h> #include <gui/console/console.h> #include <gui/console/cursor.h> #include <gui/console/clipboard.h> #include <gui/mouse.h> #include <gui/screen.h> #include <xbook/kmalloc.h> clipboard_t clipboard; int init_clipboard() { clipboard.cli...
NightfallDM/xbook2
src/arch/x86/include/arch/arch.h
#ifndef _X86_ARCH_H #define _X86_ARCH_H #include <arch/atomic.h> #include <arch/bootmem.h> #include <arch/cmos.h> #include <arch/config.h> #include <arch/gate.h> #include <arch/io.h> #include <arch/io.h> #include <arch/interrupt.h> #include <arch/instruction.h> #include <arch/page.h> #include <arch/pmem.h> #include <a...
NightfallDM/xbook2
library/xlibc/math/atan.c
/* File: atan.c Contains: For arctan(x) Written by: GUI Copyright: (C) 2017-2020 by GuEe Studio for Book OS. All rights reserved. */ #include <math.h> M_FLOAT atan(M_FLOAT x) { return (MATH_PI_4 * x - x * (fabs(x) - 1) * (0.2447 + 0.0663 * fabs(x))); }
NightfallDM/xbook2
src/task/exec.c
<gh_stars>0 #include <xbook/process.h> #include <string.h> #include <xbook/pthread.h> #include <xbook/srvcall.h> #include <xbook/vmspace.h> #include <xbook/debug.h> #include <xbook/elf32.h> #include <arch/interrupt.h> #include <arch/task.h> #include <unistd.h> #include <sys/stat.h> #include <fsal/dir.h> #in...
NightfallDM/xbook2
library/xlibc/include/sys/dir.h
<filename>library/xlibc/include/sys/dir.h #ifndef _SYS_DIR_H #define _SYS_DIR_H void build_path(const char *path, char *out_path); #endif /* _SYS_DIR_H */
NightfallDM/xbook2
library/xlibc/stdlib/labs.c
#include<stdlib.h> long int labs(long int const i) { return i>0?i:-i; }
NightfallDM/xbook2
src/include/gui/screen.h
<reponame>NightfallDM/xbook2 #ifndef __GUISRV_DRIVER_SCREEN_H__ #define __GUISRV_DRIVER_SCREEN_H__ #include <gui/color.h> typedef struct { int width; int height; /* 颜色转换 */ SCREEN_COLOR (*gui_to_screen_color)(GUI_COLOR gui_color); GUI_COLOR (*screen_to_gui_color)(SCREEN_COLOR scree...
NightfallDM/xbook2
library/xlibc/math/log2.c
/* File: log2.c Contains: For log(2)(x) Written by: GUI Copyright: (C) 2017-2020 by GuEe Studio for Book OS. All rights reserved. */ #include <math.h> M_FLOAT log2(float x) { union { float f; unsigned int i; } vx = { x }; union { unsigned int i; ...
NightfallDM/xbook2
src/arch/x86/mach-i386/task.c
#include <arch/task.h> #include <arch/interrupt.h> #include <arch/segment.h> #include <xbook/syscall.h> #include <xbook/trigger.h> #include <xbook/vmspace.h> #include <xbook/process.h> #include <xbook/debug.h> #include <string.h> void __user_trap_frame_init(trap_frame_t *frame) { /* 数据段 */ frame->ds = frame->e...
NightfallDM/xbook2
src/kernel/driver.c
#include <xbook/driver.h> #include <math.h> #include <xbook/vine.h> #include <xbook/debug.h> #include <assert.h> #include <xbook/mdl.h> #include <xbook/clock.h> #include <string.h> #include <xbook/vmspace.h> #include <sys/ioctl.h> #include <xbook/pci.h> #include <xbook/config.h> #include <xbook/vmarea.h> ...
NightfallDM/xbook2
src/include/fsal/fsal.h
#ifndef __FILESRV_FSAL_H__ #define __FILESRV_FSAL_H__ /* File system abstraction layer (FSAL) 文件系统抽象层 */ #include "../../fs/fatfs/ff.h" #include <types.h> #include <stddef.h> #include <stdint.h> #include <list.h> #define ROOT_DISK_NAME "disk0" #define ROOT_DIR_PATH "/root" #define FS_MODEL_NAME "fsal" typedef st...
NightfallDM/xbook2
src/arch/x86/include/arch/gate.h
#ifndef _X86_GATE_H #define _X86_GATE_H /* IDT 的虚拟地址 */ #define IDT_VADDR 0x80200800 #define IDT_LIMIT 0x000007ff #define DA_TaskGate 0x85 /* 任务门类型值 */ #define DA_386CGate 0x8C /* 386 调用门类型值 */ #define DA_386IGate 0x8E /* 386 中断门类型值 */ #define DA_386TGate 0x8F /* 386 陷阱门类型值 */ #define DA_GATE_DPL0 0 #...
NightfallDM/xbook2
library/xlibc/include/sys/list.h
<gh_stars>0 #ifndef _SYS_LIST_H #define _SYS_LIST_H #ifdef __cplusplus extern "C" { #endif #include <stddef.h> /* * 链表数据结构,在看了Linux的链表结构之后,觉得他那个比较通用, * 而且也比较清晰,所以我打算移植一个过来。本文件里面的都是内联函数, * 使用的时候会编译在调用的地方。并且还有很多宏定义。 */ /* * 链表结构体 */ typedef struct list { struct list *prev; struct list *next; } list_t; /...
NightfallDM/xbook2
src/include/xbook/dma.h
#ifndef _XBOOK_VMM_DMA_H #define _XBOOK_VMM_DMA_H #include <types.h> struct mm_physical_region { addr_t address; size_t size; addr_t alignment; }; struct dma_region { struct mm_physical_region p; addr_t v; }; int alloc_dma_buffer(struct dma_region *); int free_dma_buffer(struct dma_region *); #endif /* _XBO...
NightfallDM/xbook2
library/xlibc/syslib/res.c
<filename>library/xlibc/syslib/res.c<gh_stars>0 #include <sys/syscall.h> #include <sys/res.h> /** * res_open() - get device resource * * @name: res name * @flags: res flags * @arg: res arg * * res_open a device, if didn't res_open, can't operate the device. * * @return: res idx in table >= 0, -1 is fail...
NightfallDM/xbook2
src/arch/x86/include/arch/mp.h
/* *Structrue that use in "mp.c" for MultiProcessor * */ struct mp { // floating pointer uint8_t signature[4]; // "_MP_" void * physaddr; // phys addr of MP config table uint8_t length; uint8_t specrev; // [14] uint8_t checksum; // all bytes must add up to 0 uint8_t type; // MP system config type }; struct ...
NightfallDM/xbook2
src/include/sys/time.h
#ifndef _SYS_TIME_H #define _SYS_TIME_H #include <types.h> #define CLOCK_REALTIME 1 /*系统统当前时间,从1970年1.1日算起*/ #define CLOCK_MONOTONIC 2 /*系统的启动时间,不能被设置*/ #define CLOCK_PROCESS_CPUTIME_ID 3 /* 本进程运行时间*/ #define CLOCK_THREAD_CPUTIME_ID 4 /*本线程运行时间*/ struct timeval { long tv_sec; ...
NightfallDM/xbook2
src/arch/x86/include/arch/ioremap.h
<filename>src/arch/x86/include/arch/ioremap.h #ifndef _X86_IOREMAP_H #define _X86_IOREMAP_H #include <stddef.h> int __ioremap(unsigned long paddr, unsigned long vaddr, size_t size); int __iounmap(unsigned long addr, size_t size); #endif /* _X86_IOREMAP_H */
NightfallDM/xbook2
library/xlibc/socket/socket.c
<gh_stars>0 #include <unistd.h> #include <types.h> #include <stddef.h> #include <string.h> #include <ctype.h> #include <stdio.h> #include <sys/socket.h> #include <sys/syscall.h> int socket(int domain, int type, int protocol) { return syscall3(int, SYS_SOCKET, domain, type, protocol); } int bind(int sockfd, struct...
NightfallDM/xbook2
library/xlibc/stdio/fputs.c
/* * libc/stdio/fputs.c */ #include <string.h> #include <stdio.h> int fputs(const char * s, FILE * f) { return ((__stdio_write(f, (unsigned char *)s, strlen(s)) <= 0) ? EOF : 0); }
NightfallDM/xbook2
src/vmm/mdl.c
<reponame>NightfallDM/xbook2<gh_stars>0 #include <xbook/mdl.h> #include <xbook/memcache.h> #include <xbook/debug.h> #include <xbook/vmarea.h> /** * mdl_alloc - 分配一个内存描述列表 * @vaddr: 用户虚拟地址 * @length: 数据长度 * @later: 描述列表不是第一个 * @ioreq: 输入输出请求 * * 分配并映射内存,在内核中分配一个内核虚拟地址,映射到和用户的虚拟地址的物理页一样的物理页, * 相当...
NightfallDM/xbook2
library/xlibc/syslib/waitque.c
<filename>library/xlibc/syslib/waitque.c<gh_stars>0 #include <sys/syscall.h> #include <sys/waitque.h> /** * waitque_create - 创建一个等待队列 * * 返回一个等待队列句柄,成功返回>=0,失败返回-1 */ int waitque_create() { return syscall0(int, SYS_WAITQUE_CREATE); } /** * waitque_destroy - 销毁一个等待队列 * @handle: 句柄 * * 成功返回0,失败返回-1 */ int...
NightfallDM/xbook2
src/include/xbook/rwlock.h
<reponame>NightfallDM/xbook2 #ifndef _XBOOK_RWLOCK_H #define _XBOOK_RWLOCK_H /* 读写锁机制: 读者优先 写者优先 读写公平 */ #include "mutexlock.h" /* rwlock 读写优先参数 */ enum rwlock_arg { RWLOCK_RD_FIRST = 0, /* 读者优先 */ RWLOCK_WR_FIRST, /* 写着优先 */ RWLOCK_RW_FAIR, /* 读写公平 */ }; typedef struct rwlock {...
NightfallDM/xbook2
src/arch/x86/include/arch/page.h
<filename>src/arch/x86/include/arch/page.h #ifndef _ARCH_PAGE_H #define _ARCH_PAGE_H #include "interrupt.h" // 页目录类型 typedef unsigned int pde_t; // 页表类型 typedef unsigned int pte_t; //PDT = PAGE DIR TABLE //内核的页目录表物理地址 #define PAGE_DIR_PHY_ADDR 0X201000 //内核的页目录表虚拟地址 #define PAGE_DIR_VIR_ADDR 0X80201000 //PT...
NightfallDM/xbook2
user/tests/test_png.c
<filename>user/tests/test_png.c #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <png.h> #include "test.h" #define PNG_BYTES_TO_CHECK 8 #define HAVE_ALPHA 1 #define NOT_HAVE_ALPHA 0 typedef struct _pic_data pic_data; struct _pic_data { int width, height; //长宽 int bit_d...
NightfallDM/xbook2
src/include/gui/mouse.h
<reponame>NightfallDM/xbook2 #ifndef __GUISRV_DRIVER_MOUSE_H__ #define __GUISRV_DRIVER_MOUSE_H__ #include <gui/color.h> typedef struct _gui_mouse { int (*open)(void); int (*close)(void); int (*read)(void); int x, y; int last_x; /* 上次坐标 */ int ...
NightfallDM/xbook2
src/include/gui/font.h
#ifndef __GUISRV_FONT_FONT_H__ #define __GUISRV_FONT_FONT_H__ #include <types.h> #include <stdint.h> #include <gui/color.h> /* 字体数量 */ #define GUI_MAX_FONT_NR 10 #define GUI_FONT_NAME_LEN 24 #define GUI_FONT_COPYRIGHT_NAME_LEN 24 typedef struct _gui_font { char name[GUI_FONT_NAME_LEN]; /* 字体名字 */ ...
NightfallDM/xbook2
src/include/xbook/schedule.h
#ifndef _XBOOK_SCHEDULE_H #define _XBOOK_SCHEDULE_H #include "task.h" #include <list.h> #include <assert.h> #include "debug.h" /*任务优先级 */ enum task_priority { TASK_PRIO_BEST = 0, /* 最佳优先级 */ TASK_PRIO_RT, /* 实时优先级 */ TASK_PRIO_USER, /* 用户优先级 */ TASK_PRIO_IDLE, ...
NightfallDM/xbook2
library/xlibc/math/modf.c
/* File: modf.c Contains: Decompose x to get the integer and fractional parts Written by: GUI Copyright: (C) 2017-2020 by GuEe Studio for Book OS. All rights reserved. */ #include <math.h> double modf(double x, double *intptr) { if (intptr == NULL) return *(double*)NULL; do...
NightfallDM/xbook2
src/arch/x86/include/arch/pmem.h
<reponame>NightfallDM/xbook2 #ifndef _X86_PMEM_H #define _X86_PMEM_H #include "atomic.h" #include <xbook/memcache.h> // 0MB~1MB是体系结构相关的内存分布 #define BIOS_MEM_ADDR 0X000000000 #define BIOS_MEM_SIZE 0X000100000 // 1MB // 1MB~2MB是内核镜像 #define KERNEL_MEM_ADDR (BIOS_MEM_ADDR+BIO...
NightfallDM/xbook2
src/include/xbook/alarm.h
<filename>src/include/xbook/alarm.h #ifndef _XBOOK_ALARM_H #define _XBOOK_ALARM_H /* 闹钟结构 */ typedef struct alarm_struct { char flags; /* 有效标志 */ unsigned long ticks; /* ticks计数 */ unsigned long second; /* 秒数 */ } alarm_t; static inline void alarm_init(alarm_t *alarm) { a...
NightfallDM/xbook2
library/xlibc/math/sinh.c
<gh_stars>0 /* File: sinh.c Contains: For sinh(x) Written by: GUI Copyright: (C) 2017-2020 by GuEe Studio for Book OS. All rights reserved. */ #include <math.h> M_FLOAT sinh(M_FLOAT x) { double exponent = exp(x); return ((exponent - 1.0 / exponent) / 2.0); }
NightfallDM/xbook2
library/xlibc/syslib/vmm.c
#include <sys/syscall.h> #include <sys/vmm.h> /** * heap() - memory heap operate * * @heap: heap value * * if heap = 0, return current heap value. * if heap > old heap, expand heap up. * if heap < old heap, shrink heap down. * if heap = old heap, do nothing. * * @return: always return newest heap value *...
NightfallDM/xbook2
library/pthread/semaphore.c
<filename>library/pthread/semaphore.c #include <semaphore.h> #include <errno.h> #include <stddef.h> #include <sys/types.h> #include <sys/time.h> int sem_init(sem_t *sem, int pshared, unsigned int value) { if (sem == NULL || value > SEM_VALUE_MAX) { return EINVAL; } if (pshared) { return EN...
NightfallDM/xbook2
library/xlibc/unistd/mount.c
#include <unistd.h> #include <types.h> #include <stddef.h> #include <string.h> #include <math.h> #include <sys/srvcall.h> #include <srv/filesrv.h> int mount( const char *source, const char *target, const char *fstype, unsigned long flags ) { if (source == NULL || target == NULL || fstype == NULL) ...
NightfallDM/xbook2
src/include/xbook/cpu.h
<filename>src/include/xbook/cpu.h #ifndef _XBOOK_CPU_H #define _XBOOK_CPU_H #include <arch/cpu.h> static inline void cpu_pause(void) { arch_cpu_pause(); } #endif /* _XBOOK_CPU_H */
NightfallDM/xbook2
src/include/xbook/synclock.h
<reponame>NightfallDM/xbook2<filename>src/include/xbook/synclock.h /* 同步锁: 用于同步,让进程可以有序地执行 */ #ifndef _XBOOK_SYNCLOCK_H #define _XBOOK_SYNCLOCK_H #include <xbook/semaphore.h> #include <xbook/task.h> #include <assert.h> typedef struct synclock { task_t *holder; // 锁的持有者 semaphore_t semaphore; // ...
NightfallDM/xbook2
library/pthread/pthread_mutex.c
<reponame>NightfallDM/xbook2<filename>library/pthread/pthread_mutex.c #include <pthread.h> #include <sys/waitque.h> #include <sys/proc.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <errno.h> int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr) { if (!mutex) ...
NightfallDM/xbook2
src/arch/x86/include/arch/segment.h
#ifndef _X86_SEGMENT_H #define _X86_SEGMENT_H /* * 段的相关信息会出现在这个文件中 */ /* 描述符类型值说明 */ #define DA_32 0x4000 /* 32 位段 */ #define DA_G 0x8000 /* 段界限粒度为 4K 字节 */ #define DA_DPL0 0x00 /* DPL = 0 */ #define DA_DPL1 0x20 /* DPL = 1 */ #define DA_DPL2 0x40 /* DPL = 2 */ #define DA_DPL3 0x60 /* DPL ...
NightfallDM/xbook2
user/bosh/shell.h
<filename>user/bosh/shell.h #ifndef _BOSH_SHELL_H #define _BOSH_SHELL_H #include <stddef.h> #define APP_NAME "bosh" int shell_event_poll(char *buf, int pid); int shell_readline(); void shell_putchar(char ch); int shell_printf(const char *fmt, ...); #endif /* _BOSH_SHELL_H */
NightfallDM/xbook2
src/gui/font/font.c
#include <string.h> #include <gui/font.h> #include <gui/screen.h> /* 字体表,存放字体信息 */ gui_font_t font_table[GUI_MAX_FONT_NR]; gui_font_t *font_current; gui_font_t *gui_get_font(char *name) { int i; for (i = 0; i < GUI_MAX_FONT_NR; i++) { if (!strcmp(font_table[i].name, name)) { return &font_table[i]; } } ...
NightfallDM/xbook2
src/vmm/memcache.c
<filename>src/vmm/memcache.c /* * file: kernel/mm/mem_cache.c * auther: <NAME> * time: 2019/10/1 * copyright: (C) 2018-2020 by Book OS developers. All rights reserved. */ #include <arch/page.h> #include <arch/interrupt.h> #include <arch/pmem.h> #include <xbook/config.h> #include <xbook/memcache.h> ...