Skip to content

Commit

Permalink
✨ 179 版本 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenBaby committed Aug 16, 2023
1 parent b8ee265 commit 6cd3806
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 25 deletions.
33 changes: 8 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,20 @@

- [参考文献](./docs/others/参考文献.md)

## 开发中的功能
## 使用方法

### 硬件驱动:
iso 文件的使用参考 [版本 1.0.0](./docs/13%20系统优化/179%20版本%201.0.0.md)

- [x] CPU 功能检测
- [x] FPU 支持
- [ ] ACPI:控制关机和重启 [@lihanrui2913](https://github.com/lihanrui2913)
- [x] ISA 总线
- [x] 💾 软盘驱动
- [x] 📣 Sound Blaster16 驱动
- [x] 💿 ATAPI 光盘驱动
- [x] PCI 总线枚举
- [x] IDE 硬盘 DMA
- [x] 网卡驱动 E1000
- [x] 网卡驱动 RTL8139
对于 `qemu` 模拟器,需要提前配置 `tap0` 设备,用于网络:

### 文件系统
qemu-system-i386 -m 32M -audiodev pa,id=snd -machine pcspk-audiodev=snd -device sb16,audiodev=snd -rtc base=localtime -chardev stdio,mux=on,id=com1 -serial chardev:com1 -netdev tap,id=eth0,ifname=tap0,script=no,downscript=no -device e1000,netdev=eth0 -drive file=onix_1.0.0.iso,media=cdrom,if=ide -boot d

- [x] 虚拟文件系统
- [x] ISO 9660 文件系统
## 开发中的功能

### 网络协议栈
### 硬件驱动

- [x] Ether
- [x] ARP
- [x] IP
- [x] ICMP
- [x] UDP
- [ ] TCP
- [ ] DNS
- [ ] HTTP
- [ ] ACPI:控制关机和重启 [@lihanrui2913](https://github.com/lihanrui2913)
- [x] 网卡驱动 RTL8139

## Pull Request 约定

Expand Down
38 changes: 38 additions & 0 deletions docs/13 系统优化/179 版本 1.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 版本 1.0.0

哈哈!版本 1.0.0 发布!!!,发布 `onix_1.0.0.iso` 文件;

![](../others/images/snapshot.png)

## uname 系统调用

用于获取简单的系统信息;

## 配置方式

## qemu

需要提前配置 `tap0` 设备,用于网络;

```sh
qemu-system-i386 -m 32M -audiodev pa,id=snd -machine pcspk-audiodev=snd -device sb16,audiodev=snd -rtc base=localtime -chardev stdio,mux=on,id=com1 -serial chardev:com1 -netdev tap,id=eth0,ifname=tap0,script=no,downscript=no -device e1000,netdev=eth0 -drive file=onix_1.0.0.iso,media=cdrom,if=ide -boot d
```

## vmware

修改虚拟机 `.vmx` 文件,添加如下内容,另外可能需要添加一个串口设备:

```sh
# 声霸卡
sound.present = "TRUE"
sound.virtualDev = "sb16"
sound.opl3.enabled = "TRUE"
sound.autodetect = "TRUE"
sound.baseAddr = "0x220"
sound.dma16 = "5"
sound.dma8 = "1"
sound.irq = "5"

# e1000 网卡
ethernet0.virtualDev = "e1000"
```
Binary file modified docs/others/images/snapshot.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions src/builtin/uname.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <onix/types.h>
#include <onix/stdio.h>
#include <onix/syscall.h>
#include <onix/uname.h>
#include <onix/string.h>

int main(int argc, char const *argv[], char const *envp[])
{
utsname_t name;
int ret = uname(&name);
if (ret < 0)
{
printf(strerror(ret));
return ret;
}
printf("%s_%s\n", name.sysname, name.version);
return 0;
}
4 changes: 4 additions & 0 deletions src/include/onix/onix.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
// 内核魔数,用于校验错误
#define ONIX_MAGIC 0x20220205

#ifndef ONIX_VERSION
#define ONIX_VERSION "1.0.0"
#endif

#endif
3 changes: 3 additions & 0 deletions src/include/onix/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typedef enum syscall_t
SYS_NR_SIGNAL = 48,
SYS_NR_IOCTL = 54,
SYS_NR_SETPGID = 57,
SYS_NR_UNAME = 59,
SYS_NR_UMASK = 60,
SYS_NR_CHROOT = 61,
SYS_NR_DUP2 = 63,
Expand Down Expand Up @@ -223,4 +224,6 @@ int sendmsg(int fd, msghdr_t *msg, u32 flags);

int resolv(const char *name, ip_addr_t addr);

int uname(void *buf);

#endif
15 changes: 15 additions & 0 deletions src/include/onix/uname.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef ONIX_UNAME_H
#define ONIX_UNAME_H

#include <onix/types.h>

typedef struct utsname_t
{
char sysname[9]; // 本版本操作系统的名称
char nodename[9]; // 与实现相关的网络中节点名称
char release[9]; // 本实现的当前发行级别
char version[9]; // 本次发行的版本级别
char machine[9]; // 系统运行的硬件类型名称
} utsname_t;

#endif
4 changes: 4 additions & 0 deletions src/kernel/gate.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ extern int sys_sendmsg();

extern int sys_resolv();

extern int sys_uname();

void syscall_init()
{
for (size_t i = 0; i < SYSCALL_SIZE; i++)
Expand Down Expand Up @@ -195,4 +197,6 @@ void syscall_init()
syscall_table[SYS_NR_SHUTDOWN] = sys_shutdown;

syscall_table[SYS_NR_RESOLV] = sys_resolv;

syscall_table[SYS_NR_UNAME] = sys_uname;
}
21 changes: 21 additions & 0 deletions src/kernel/uname.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <onix/uname.h>
#include <onix/memory.h>
#include <onix/task.h>
#include <onix/string.h>
#include <onix/debug.h>
#include <onix/errno.h>

#define LOGK(fmt, args...) DEBUGK(fmt, ##args)

int sys_uname(utsname_t *buf)
{
if (!memory_access(buf, sizeof(utsname_t), true, running_task()->uid))
return -EINVAL;

strncpy(buf->sysname, "onix", 9);
strncpy(buf->nodename, "onix", 9);
strncpy(buf->release, "release", 9);
strncpy(buf->version, ONIX_VERSION, 9);
strncpy(buf->machine, "machine", 9);
return EOK;
}
5 changes: 5 additions & 0 deletions src/lib/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,8 @@ int resolv(const char *name, ip_addr_t addr)
{
return _syscall2(SYS_NR_RESOLV, (u32)name, (u32)addr);
}

int uname(void *buf)
{
return _syscall1(SYS_NR_UNAME, (u32)buf);
}
5 changes: 5 additions & 0 deletions src/makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
BUILD:=../build
SRC:=.

ONIX_VERSION:=1.0.0
MULTIBOOT2:=0x18000
ENTRYPOINT:=$(shell python -c "print(f'0x{$(MULTIBOOT2) + 0x8000:x}')")

Expand All @@ -15,6 +16,8 @@ CFLAGS+= -fno-stack-protector # 不需要栈保护
CFLAGS+= -Werror
CFLAGS+= -DONIX # 定义 ONIX
CFLAGS+= -DONIX_DEBUG # 定义 ONIX_DEBUG
CFLAGS+= -DONIX_VERSION='"$(ONIX_VERSION)"' # 定义 ONIX_VERSION

CFLAGS:=$(strip ${CFLAGS})

DEBUG:= -g
Expand Down Expand Up @@ -73,6 +76,7 @@ BUILTIN_APPS := \
$(BUILD)/builtin/ifconfig.out \
$(BUILD)/builtin/ping.out \
$(BUILD)/builtin/httpd.out \
$(BUILD)/builtin/uname.out \
$(BUILD)/builtin/tcp_server.out \
$(BUILD)/builtin/tcp_client.out \
$(BUILD)/builtin/tcp_nagle.out \
Expand All @@ -93,6 +97,7 @@ $(BUILD)/kernel.bin: \
$(BUILD)/kernel/start.o \
$(BUILD)/kernel/onix.o \
$(BUILD)/kernel/main.o \
$(BUILD)/kernel/uname.o \
$(BUILD)/kernel/io.o \
$(BUILD)/kernel/mio.o \
$(BUILD)/kernel/device.o \
Expand Down
1 change: 1 addition & 0 deletions src/utils/cdrom.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ $(BUILD)/kernel.iso : \
cp $(SRC)/utils/grub.cfg $(BUILD)/iso/boot/grub
# 生成 iso 文件
grub-mkrescue -o $@ $(BUILD)/iso
cp $@ $(BUILD)/onix_$(ONIX_VERSION).iso

.PHONY: bochsb
bochsb: $(BUILD)/kernel.iso
Expand Down

0 comments on commit 6cd3806

Please sign in to comment.