Skip to content

Commit 7ad8dbe

Browse files
修复文件描述符回收的时机, 更新 README 库使用记录.
更新内核版本号. Co-authored-by: suhuajun-github <115517663+suhuajun-github@users.noreply.github.com>
1 parent c0d6511 commit 7ad8dbe

File tree

7 files changed

+46
-29
lines changed

7 files changed

+46
-29
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
Languages
1818
: *English*
1919
| [简体中文](readme/README-zh-CN.md)
20-
| [Français](readme/README-fr-FR.md)
21-
| [日本語](readme/README-ja-JP.md)
2220

2321
## Introduction
2422

@@ -32,6 +30,10 @@ and [amd64](https://en.wikipedia.org/wiki/X86-64) architecture.
3230
- `plant-vfs` by min0911Y [plos-clan/plant-vfs](https://github.com/plos-clan/plant-vfs)
3331
- `EEVDF` by xiaoyi1212 [plos-clan/EEVDF](https://github.com/plos-clan/EEVDF)
3432
- `libfdt` by osdev [osdev/libfdt](https://codeberg.org/OSDev/libfdt)
33+
- `acpica` by acpica [acpica/acpica](https://github.com/acpica/acpica)
34+
- `stb_sprintf` by nothing [nothing/stb](https://github.com/nothings/stb)
35+
- `tinycrypt` by intel [intel/tinycrypt](https://github.com/intel/tinycrypt)
36+
- `zstd` by facebook [facebook/zstd](https://github.com/facebook/zstd)
3537

3638
## Build & Run
3739

@@ -83,4 +85,4 @@ Welcome to create pull requests or issues to this project. Then sit back and rel
8385

8486
### Contributors
8587

86-
* Goto [CoolPotOS | Website](cpos.plos-clan.org) to see the contributors list.
88+
* Goto [CoolPotOS | Website](cpos.plos-clan.org) to see the contributors list.

readme/README-zh-CN.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
Languages
1818
: [English](../README.md)
1919
| *简体中文*
20-
| [Français](README-fr-FR.md)
21-
| [日本語](/readme/README-ja-JP.md)
2220

2321
## 介绍
2422

@@ -32,6 +30,10 @@ Languages
3230
- `plant-vfs` 来自 min0911Y [plos-clan/plant-vfs](https://github.com/plos-clan/plant-vfs)
3331
- `EEVDF` 来自 xiaoyi1212 [plos-clan/EEVDF](https://github.com/plos-clan/EEVDF)
3432
- `libfdt` 来自 osdev [osdev/libfdt](https://codeberg.org/OSDev/libfdt)
33+
- `acpica` 来自 acpica [acpica/acpica](https://github.com/acpica/acpica)
34+
- `stb_sprintf` 来自 nothing [nothing/stb](https://github.com/nothings/stb)
35+
- `tinycrypt` 来自 intel [intel/tinycrypt](https://github.com/intel/tinycrypt)
36+
- `zstd` 来自 facebook [facebook/zstd](https://github.com/facebook/zstd)
3537

3638
## 构建与运行
3739

@@ -41,11 +43,12 @@ Languages
4143
- xorriso
4244
- QEMU
4345
- git (`GIT_VERSION` 宏哈希获取)
44-
- clang
46+
- clang
4547
- lld
4648
- openssl (内核签名密钥生成)
4749
- python3 `cryptography` (签名内核模块)
48-
-
50+
-
51+
4952
### 参数
5053

5154
你可以在命令行指定需要编译的 CoolPotOS 架构 (默认为 `x86_64`):

src/arch/x86_64/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "cpu_features.h"
44
#include "description_table.h"
55
#include "driver/acpi.h"
6-
#include "driver/ahci.h"
76
#include "driver/blk_device.h"
87
#include "driver/char/ps2_kbd.h"
98
#include "driver/drm/drm_device.h"
@@ -15,6 +14,7 @@
1514
#include "driver/power/power.h"
1615
#include "driver/serial.h"
1716
#include "driver/tty.h"
17+
#include "driver/usb/xhci.h"
1818
#include "exec/dlinker.h"
1919
#include "exec/elf_load.h"
2020
#include "fpu.h"
@@ -109,7 +109,7 @@ USED _Noreturn void kmain() {
109109
kmodule_init();
110110

111111
zero_setup();
112-
// ahci_setup();
112+
usb_setup();
113113
// nvme_setup();
114114
drm_plainfb_init();
115115

src/driver/usb/xhci.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "driver/usb/xhci.h"
2+
#include "driver/pci/pci.h"
3+
4+
void load_xhci_device(pci_device_t *device) {}
5+
6+
void usb_setup() {
7+
//pci_find_class(, load_xhci_device);
8+
}

src/include/driver/usb/xhci.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
3+
void usb_setup();

src/include/metadata.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
# undef KERNEL_ARCH
3939
# undef KERNEL_ARCH_VERSION
4040
# define KERNEL_ARCH "x86_64"
41-
# define KERNEL_ARCH_VERSION "39"
41+
# define KERNEL_ARCH_VERSION "40"
4242
# define ARCH_HAS_OPTIMIZED_MEMCPY 1
4343
# define ARCH_HAS_OPTIMIZED_MEMSET 1
4444
# define ARCH_HAS_OPTIMIZED_MEMCMP 1

src/task/task.c

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ _Atomic volatile pid_t now_pid = 0;
1919
_Atomic volatile pid_t now_tid = 0;
2020
extern volatile bool smp_enable;
2121

22-
USED void foreach_task(){
22+
USED void foreach_task() {
2323
pcb_t process = NULL;
24-
cow_foreach(process_list,process) {
25-
logkf("PID:%d - %s %p\n\r",process->pid,process->name,process);
24+
cow_foreach(process_list, process) {
25+
logkf("PID:%d - %s %p\n\r", process->pid, process->name, process);
2626
tcb_t thread = NULL;
27-
cow_foreach(process->child_threads,thread) {
28-
logkf("\t TID:%d - %s %p\n\r",thread->tid,thread->name,thread);
27+
cow_foreach(process->child_threads, thread) {
28+
logkf("\t TID:%d - %s %p\n\r", thread->tid, thread->name, thread);
2929
struct sched_entity *entity = thread->sched_handle;
3030
//logkf("\t deadline: %x - vruntime: %x\n\r",entity->deadline,entity->vruntime);
31-
logkf("\t deadline: %lx - vruntime: %lx\n\r",entity->deadline,entity->vruntime);
31+
logkf("\t deadline: %lx - vruntime: %lx\n\r", entity->deadline, entity->vruntime);
3232
}
3333
}
3434
}
@@ -66,7 +66,7 @@ static void kill_thread0(pcb_t parent, tcb_t task) {
6666

6767
static void kill_proc0(pcb_t pcb) {
6868
do {
69-
if(pcb->child_threads->size == 0) break;
69+
if (pcb->child_threads->size == 0) break;
7070
tcb_t thread = NULL;
7171
cow_foreach(pcb->child_threads, thread) {
7272
break;
@@ -82,19 +82,11 @@ static void kill_proc0(pcb_t pcb) {
8282

8383
procfs_on_exit_task(pcb);
8484

85-
for (size_t i = 0; i < pcb->fdts->fds_length; i++) {
86-
fd_t *handle = pcb->fdts->fds[i];
87-
if (handle != NULL) {
88-
vfs_close(handle->node);
89-
free(handle);
90-
}
91-
}
92-
9385
lazy_free(pcb);
9486

9587
free_fdt(pcb->fdts);
9688
ipc_queue_release(pcb->ipc_queue);
97-
free_llist_queue(pcb->virt_queue,NULL,NULL);
89+
free_llist_queue(pcb->virt_queue, NULL, NULL);
9890
free(pcb->cmdline);
9991
vfs_close(pcb->cwd);
10092
vfs_close(pcb->exec);
@@ -135,7 +127,7 @@ void kill_proc(pcb_t pcb, int exit_code, bool is_zombie) {
135127
}
136128
}
137129
pcb_t parent = pcb->parent;
138-
cow_list_remove(parent->child_process,pcb->ppl_index);
130+
cow_list_remove(parent->child_process, pcb->ppl_index);
139131
pcb->status = T_ZOMBIE;
140132
ipc_message_t msg = malloc(sizeof(struct ipc_message));
141133
msg->pid = pcb->pid;
@@ -145,6 +137,15 @@ void kill_proc(pcb_t pcb, int exit_code, bool is_zombie) {
145137
msg->data[2] = (exit_code >> 16) & 0xFF;
146138
msg->data[3] = (exit_code >> 24) & 0xFF;
147139
ipc_send(pcb->parent->ipc_queue, msg);
140+
141+
for (size_t i = 0; i < pcb->fdts->fds_length; i++) {
142+
fd_t *handle = pcb->fdts->fds[i];
143+
if (handle != NULL) {
144+
vfs_close(handle->node);
145+
free(handle);
146+
}
147+
}
148+
148149
enable_scheduler();
149150
} else {
150151
cow_list_remove(pcb->parent->child_process, pcb->ppl_index);
@@ -164,7 +165,7 @@ int waitpid(pid_t pid, pid_t *pid_ret) {
164165
int exit_code;
165166
while (1) {
166167
change_task_weight(get_current_task(), NICE_TO_PRIO(10));
167-
mesg = ipc_recv_wait(process->ipc_queue,IPC_MSG_TYPE_EPID);
168+
mesg = ipc_recv_wait(process->ipc_queue, IPC_MSG_TYPE_EPID);
168169
change_task_weight(get_current_task(), NICE_TO_PRIO(0));
169170
exit_code =
170171
(mesg->data[3] << 24) | (mesg->data[2] << 16) | (mesg->data[1] << 8) | mesg->data[0];
@@ -251,6 +252,6 @@ void setup_task() {
251252
bsp_idle_thread->status = T_RUNNING;
252253
bsp_idle_thread->signal_stack = (uint64_t)aligned_alloc(PAGE_SIZE, STACK_SIZE) + STACK_SIZE;
253254
bsp_idle_thread->syscall_stack = (uint64_t)aligned_alloc(PAGE_SIZE, STACK_SIZE) + STACK_SIZE;
254-
arch_context_init(bsp_idle_thread,&bsp_idle_thread->context);
255+
arch_context_init(bsp_idle_thread, &bsp_idle_thread->context);
255256
kinfo("kernel process(%s) PID: %d ", kernel_process->name, kernel_process->pid);
256257
}

0 commit comments

Comments
 (0)