Merge pull request #43 from liricliu/master

This commit is contained in:
login 2022-09-15 23:31:32 +08:00 committed by GitHub
commit 44d1648e37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 120 additions and 11 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
DragonOS.iso
.idea/
kernel/kernel
.DS_Store
*.o
*.s

View File

@ -138,7 +138,8 @@
"devfs.h": "c",
"devfs-types.h": "c",
"chardev.h": "c",
"rootfs.h": "c"
"rootfs.h": "c",
"tty.h": "c"
},
"C_Cpp.errorSquiggles": "Enabled",
"esbonio.sphinx.confDir": ""

View File

@ -22,8 +22,8 @@ kernel_subdirs := common driver process debug filesystem time arch exception mm
head.o: head.S
gcc -E head.S > head.s # 预处理
as $(ASFLAGS) -o head.o head.s
gcc -E head.S > _head.s # 预处理
as $(ASFLAGS) -o head.o _head.s
main.o: main.c

View File

@ -1,7 +1,7 @@
CFLAGS += -I .
kernel_driver_subdirs:=video interrupt usb pci uart acpi disk keyboard mouse multiboot2 timers
kernel_driver_subdirs:=video interrupt usb pci uart acpi disk keyboard mouse multiboot2 timers tty
ECHO:
@echo "$@"

View File

@ -0,0 +1,8 @@
all: tty.o
CFLAGS += -I .
tty.o: tty.c
gcc $(CFLAGS) -c tty.c -o tty.o

92
kernel/driver/tty/tty.c Normal file
View File

@ -0,0 +1,92 @@
#include <filesystem/devfs/devfs.h>
#include <filesystem/VFS/VFS.h>
#include "tty.h"
static int tty_private_data;
/**
* @brief tty文件
*
* @param inode inode
* @param filp
* @return long
*/
long tty_open(struct vfs_index_node_t *inode, struct vfs_file_t *filp)
{
filp->private_data = &tty_private_data;
return 0;
}
/**
* @brief tty文件
*
* @param inode inode
* @param filp
* @return long
*/
long tty_close(struct vfs_index_node_t *inode, struct vfs_file_t *filp)
{
filp->private_data = NULL;
return 0;
}
/**
* @brief tty控制接口
*
* @param inode inode
* @param filp tty文件指针
* @param cmd
* @param arg
* @return long
*/
long tty_ioctl(struct vfs_index_node_t *inode, struct vfs_file_t *filp, uint64_t cmd, uint64_t arg)
{
switch (cmd)
{
default:
break;
}
return 0;
}
/**
* @brief tty文件的操作接口
*
* @param filp
* @param buf
* @param count
* @param position
* @return long
*/
long tty_read(struct vfs_file_t *filp, char *buf, int64_t count, long *position)
{
return 0;
}
/**
* @brief tty文件写入接口
*
* @param filp
* @param buf
* @param count
* @param position
* @return long
*/
long tty_write(struct vfs_file_t *filp, char *buf, int64_t count, long *position)
{
return 0;
}
struct vfs_file_operations_t tty_fops={
.open = tty_open,
.close = tty_close,
.ioctl = tty_ioctl,
.read = tty_read,
.write = tty_write,
};
void tty_init(){
//注册devfs
devfs_register_device(DEV_TYPE_CHAR, CHAR_DEV_STYPE_TTY, &tty_fops);
kinfo("tty driver registered.");
}

3
kernel/driver/tty/tty.h Normal file
View File

@ -0,0 +1,3 @@
#pragma once
void tty_init();

View File

@ -5,8 +5,8 @@ CFLAGS += -I .
all: entry.o irq.o softirq.o trap.o
entry.o: entry.S
gcc -E entry.S > entry.s
as $(ASFLAGS) -o entry.o entry.s
gcc -E entry.S > _entry.s
as $(ASFLAGS) -o entry.o _entry.s
trap.o: trap.c
gcc $(CFLAGS) -c trap.c -o trap.o

View File

@ -22,6 +22,7 @@ static char chardev_name_prefix[CHAR_DEV_STYPE_END + 1][32] = {
[CHAR_DEV_STYPE_USB_KEYBOARD] = "usb.kb",
[CHAR_DEV_STYPE_BLUETOOTH_MOUSE] = "bt.mse",
[CHAR_DEV_STYPE_BLUETOOTH_KEYBOARD] = "bt.kb",
[CHAR_DEV_STYPE_TTY] = "vdev.tty",
[CHAR_DEV_STYPE_END] = "",
};
/**

View File

@ -29,6 +29,7 @@ enum
CHAR_DEV_STYPE_USB_MOUSE,
CHAR_DEV_STYPE_BLUETOOTH_MOUSE,
CHAR_DEV_STYPE_BLUETOOTH_KEYBOARD,
CHAR_DEV_STYPE_TTY,
CHAR_DEV_STYPE_END, // 结束标志
};

View File

@ -26,6 +26,7 @@
#include "driver/multiboot2/multiboot2.h"
#include "driver/acpi/acpi.h"
#include "driver/keyboard/ps2_keyboard.h"
#include "driver/tty/tty.h"
#include "driver/mouse/ps2_mouse.h"
#include "driver/disk/ata.h"
#include "driver/pci/pci.h"
@ -145,6 +146,7 @@ void system_initialize()
devfs_init();
cpu_init();
ps2_keyboard_init();
tty_init();
// ps2_mouse_init();
// ata_init();
pci_init();

View File

@ -6,8 +6,8 @@ CFLAGS += -I .
procs.o: proc.S
gcc -E proc.S > proc.s
as $(ASFLAGS) -o procs.o proc.s
gcc -E proc.S > _proc.s
as $(ASFLAGS) -o procs.o _proc.s
process.o: process.c
gcc $(CFLAGS) -c process.c -o process.o

View File

@ -6,8 +6,8 @@ all: apu_boot.o smp.o
apu_boot.o: apu_boot.S
gcc -E apu_boot.S > apu_boot.s # 预处理
as $(ASFLAGS) -o apu_boot.o apu_boot.s
gcc -E apu_boot.S > _apu_boot.s # 预处理
as $(ASFLAGS) -o apu_boot.o _apu_boot.s
smp.o: smp.c
gcc $(CFLAGS) -c smp.c -o smp.o

2
run.sh
View File

@ -159,7 +159,7 @@ qemu_trace_usb=trace:usb_xhci_reset,trace:usb_xhci_run,trace:usb_xhci_stop,trace
qemu_accel=kvm
if [ "${OS}" == "Darwin" ]; then
if [ $(uname) == Darwin ]; then
qemu_accel=hvf
fi