Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
锟斤拷有点烫
cunix
提交
9a05fbf3
C
cunix
项目概览
锟斤拷有点烫
/
cunix
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
cunix
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9a05fbf3
编写于
3月 13, 2021
作者:
R
rain
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make assembly macros
上级
03e631dc
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
72 addition
and
11 deletion
+72
-11
LINES
LINES
+2
-0
README.md
README.md
+3
-0
include/arch/sys.h
include/arch/sys.h
+44
-0
include/kernel/init.h
include/kernel/init.h
+4
-0
include/kernel/print.h
include/kernel/print.h
+1
-1
include/kernel/vgatext.h
include/kernel/vgatext.h
+3
-0
kernel/Makefile
kernel/Makefile
+1
-1
kernel/hal/vgatext/vgatext.c
kernel/hal/vgatext/vgatext.c
+5
-3
kernel/init/Makefile
kernel/init/Makefile
+1
-1
kernel/init/main.c
kernel/init/main.c
+6
-3
kernel/init/print.c
kernel/init/print.c
+2
-2
未找到文件。
LINES
浏览文件 @
9a05fbf3
...
...
@@ -26,3 +26,5 @@
2021-3-12 1.384: 1384 lines, 20 files, rain
2021-3-13 1.440: 1440 lines, 21 files, rain
README.md
浏览文件 @
9a05fbf3
...
...
@@ -58,3 +58,6 @@ Cunix kernel
`1.384s-hal`
:
use text VGA mode, and make a file-operations of it.
`1.440s-lib`
:
make some macros about assembly
include/arch/sys.h
0 → 100644
浏览文件 @
9a05fbf3
/* Copyright (C) 2021 Rain */
/* This file is part of Cunix. */
/*
Cunix is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) and later version.
*/
/*
Cunix is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
/*
You should have received a copy of the GNU General Public License
along with Cunix. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef INCLUDED_SYS_H
#define INCLUDED_SYS_H
#include <kernel/types.h>
#define sgdt(addr) __asm__ __volatile__ ("sgdt %0" : "=m" (addr) : :)
#define lgdt(addr) __asm__ __volatile__ ("lgdt %0" : : "m" (addr))
#define sidt(addr) __asm__ __volatile__ ("sidt %0" : "=m" (addr) : :)
#define lidt(addr) __asm__ __volatile__ ("lidt %0" : : "m" (addr))
#define pause() __asm__ __volatile__ ("pause");
#define nop() __asm__ __volatile__ ("nop");
#define hlt() __asm__ __volatile__ ("hlt");
#endif
include/kernel/init.h
浏览文件 @
9a05fbf3
...
...
@@ -33,6 +33,10 @@
#define KERNEL_CS 0x0008
#define KERNEL_DS 0x0010
struct
inode_desc
{
/* this struct is a general descriptor, so we must know
* how big is it. */
...
...
include/kernel/print.h
浏览文件 @
9a05fbf3
...
...
@@ -33,7 +33,7 @@
#include <kernel/vgatext.h>
__uint32_t
print
(
struct
vga_inode
*
inode
,
char
*
s
);
__uint32_t
print
(
char
*
s
);
#endif
include/kernel/vgatext.h
浏览文件 @
9a05fbf3
...
...
@@ -40,6 +40,7 @@
extern
struct
file_operations
vga
;
struct
vga_inode
{
struct
inode_desc
inode
;
...
...
@@ -55,5 +56,7 @@ struct vga_inode {
__uint32_t
x
,
y
;
};
extern
struct
vga_inode
stdout
;
#endif
kernel/Makefile
浏览文件 @
9a05fbf3
...
...
@@ -4,7 +4,7 @@ default:
make
-C
lib/
make kernel.bin
kernel.o
:
init/main.o hal/vgatext/vgatext.o lib/bitmap.o lib/bitman.o init/print.o
kernel.o
:
init/main.o hal/vgatext/vgatext.o lib/bitmap.o lib/bitman.o init/print.o
ld
-b
elf64-x86-64
-o
kernel.o init/main.o init/print.o hal/vgatext/vgatext.o lib/bitmap.o lib/bitman.o
-T
kernel.lds
kernel.bin
:
kernel.o
...
...
kernel/hal/vgatext/vgatext.c
浏览文件 @
9a05fbf3
...
...
@@ -38,6 +38,8 @@
__uint32_t
next_fd
=
1
;
struct
vga_inode
stdout
;
struct
inode_desc
*
vga_open
(
char
*
name
,
__uint32_t
type
,
__uint32_t
mode
,
errno_t
*
errno
)
{
*
errno
=
-
E_NOSUPP
;
...
...
@@ -137,9 +139,9 @@ errno_t vga_write(struct vga_inode *inode, char *buffer, __uint64_t l) {
}
e
rrno_t
vga_lseek
(
struct
inode_desc
*
inode
,
__uint32_t
off
,
__uint32_t
seg
)
{
return
-
E_HNOSUP
;
}
e
xtern
errno_t
vga_lseek
(
struct
inode_desc
*
inode
,
__uint32_t
off
,
__uint32_t
seg
);
__asm__
(
"vga_lseek: ret
\n
"
);
void
vga_close
(
struct
inode_desc
*
inode
)
{
...
...
kernel/init/Makefile
浏览文件 @
9a05fbf3
C_FLAGS
=
-mcmodel
=
large
-fno-builtin
-m64
-I
../../include/
all
:
main.o print.o
all
:
main.o print.o
%.o
:
%.c
gcc
-c
$*
.c
$(C_FLAGS)
...
...
kernel/init/main.c
浏览文件 @
9a05fbf3
...
...
@@ -28,13 +28,16 @@
#include <kernel/types.h>
#include <kernel/errno.h>
#include <kernel/int.h>
#include <kernel/vgatext.h>
#include <kernel/print.h>
void
init
(
void
)
{
struct
vga_inode
vi
;
vga
.
fill
(
NULL
,
0
,
0
,
&
vi
);
print
(
&
vi
,
"kernel starting
\n
"
);
vga
.
fill
(
NULL
,
0
,
0
,
&
stdout
);
print
(
"kernel starting
\n
"
);
for
(;;);
}
kernel/init/print.c
浏览文件 @
9a05fbf3
...
...
@@ -31,9 +31,9 @@
#include <kernel/vgatext.h>
errno_t
print
(
struct
vga_inode
*
inode
,
char
*
s
)
{
errno_t
print
(
char
*
s
)
{
for
(;
*
s
;
s
++
)
{
vga
.
write
(
inode
,
s
,
1
);
vga
.
write
(
&
stdout
,
s
,
1
);
}
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录