Merge branch 'usb'

This commit is contained in:
fslongjin 2022-07-18 21:20:24 +08:00
commit 98371a9b4a
6 changed files with 40 additions and 3 deletions

View File

@ -108,7 +108,8 @@
"ahci.h": "c",
"slab.h": "c",
"boot_info.h": "c",
"pci.h": "c"
"pci.h": "c",
"time.h": "c"
},
"C_Cpp.errorSquiggles": "Enabled",
"esbonio.sphinx.confDir": ""

View File

@ -37,6 +37,14 @@ struct timespec
*/
extern int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
/**
* @brief
*
* @param usec
* @return int
*/
extern int usleep(useconds_t usec);
/**
* @brief CPU时间
*

View File

@ -154,9 +154,10 @@ void system_initialize()
// fat32_init();
HPET_enable();
usb_init();
// 系统初始化到此结束,剩下的初始化功能应当放在初始内核线程中执行
apic_timer_init();
}
//操作系统内核从这里开始执行

View File

@ -6,6 +6,7 @@
#include <common/compiler.h>
#include <common/libELF/elf.h>
#include <driver/video/video.h>
#include <driver/usb/usb.h>
#include <exception/gate.h>
#include <filesystem/fat32/fat32.h>
#include <mm/slab.h>
@ -410,7 +411,10 @@ ul initial_kernel_thread(ul arg)
// kinfo("initial proc running...\targ:%#018lx", arg);
fat32_init();
usb_init();
// 准备切换到用户态
struct pt_regs *regs;
current_pcb->thread->rip = (ul)ret_from_system_call;

View File

@ -59,4 +59,20 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
}
return 0;
}
}
/**
* @brief
*
* @param usec
* @return int
*/
int usleep(useconds_t usec)
{
struct timespec ts = {
tv_sec : (long int)(usec / 1000000),
tv_nsec : (long int)(usec % 1000000) * 1000UL
};
return nanosleep(&ts, NULL);
}

View File

@ -14,3 +14,10 @@
*/
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
/**
* @brief
*
* @param usec
* @return int
*/
int usleep(useconds_t usec);