Compare commits
No commits in common. "90436a4f46dec5ce3cc341e981b9aaf9f4e79605" and "1c2cd75c72a7db4df527b5f928c08686856bd20b" have entirely different histories.
90436a4f46
...
1c2cd75c72
2
Makefile
2
Makefile
@ -3,7 +3,7 @@ CPPFLAGS = -MMD
|
|||||||
AS=nasm
|
AS=nasm
|
||||||
ASFLAGS += -f elf32
|
ASFLAGS += -f elf32
|
||||||
LDFLAGS += -m elf_i386
|
LDFLAGS += -m elf_i386
|
||||||
CFLAGS += -m32 -pipe -Wall -Wextra -Werror -ffreestanding -fno-exceptions -fno-pie -fno-stack-protector -fno-tree-vectorize -D__KERNEL__
|
CFLAGS += -m32 -Wall -Wextra -Werror -ffreestanding -fno-exceptions -fno-pie -fno-stack-protector -fno-tree-vectorize -D__KERNEL__
|
||||||
#keep .i and .s
|
#keep .i and .s
|
||||||
#CFLAGS += -save-temps
|
#CFLAGS += -save-temps
|
||||||
#CFLAGS += -fanalyzer -Wno-analyzer-malloc-leak -Wno-analyzer-out-of-bounds
|
#CFLAGS += -fanalyzer -Wno-analyzer-malloc-leak -Wno-analyzer-out-of-bounds
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "uaddrspace.h"
|
#include "uaddrspace.h"
|
||||||
#include "zero.h"
|
#include "zero.h"
|
||||||
|
|
||||||
|
|
||||||
int syscallExecute(int syscallId, const struct cpu_state *userCtx)
|
int syscallExecute(int syscallId, const struct cpu_state *userCtx)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -145,17 +146,6 @@ int syscallExecute(int syscallId, const struct cpu_state *userCtx)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SYSCALL_ID_USLEEP: {
|
|
||||||
unsigned int sleep;
|
|
||||||
|
|
||||||
ret = syscallGet1arg(userCtx, &sleep);
|
|
||||||
if (ret)
|
|
||||||
break;
|
|
||||||
|
|
||||||
ret = threadUsleep(sleep);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
printf("Unknon syscall id %d\n", syscallId);
|
printf("Unknon syscall id %d\n", syscallId);
|
||||||
ret = -ENOENT;
|
ret = -ENOENT;
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#define SYSCALL_ID_MMAP 7
|
#define SYSCALL_ID_MMAP 7
|
||||||
#define SYSCALL_ID_MUNMAP 8
|
#define SYSCALL_ID_MUNMAP 8
|
||||||
#define SYSCALL_ID_NEW_THREAD 9
|
#define SYSCALL_ID_NEW_THREAD 9
|
||||||
#define SYSCALL_ID_USLEEP 10
|
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
int syscallExecute(int syscallId, const struct cpu_state *user_ctx);
|
int syscallExecute(int syscallId, const struct cpu_state *user_ctx);
|
||||||
|
@ -292,11 +292,6 @@ int threadYield()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int threadMsleep(unsigned long msec)
|
int threadMsleep(unsigned long msec)
|
||||||
{
|
|
||||||
return threadUsleep(msec*1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
int threadUsleep(unsigned long usec)
|
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
struct thread *next, *current;
|
struct thread *next, *current;
|
||||||
@ -304,12 +299,12 @@ int threadUsleep(unsigned long usec)
|
|||||||
disable_IRQs(flags);
|
disable_IRQs(flags);
|
||||||
|
|
||||||
current = currentThread;
|
current = currentThread;
|
||||||
assertmsg(current->state == RUNNING, "thread %s is in state %d for %lu us\n", current->name,
|
assertmsg(current->state == RUNNING, "thread %s is in state %d for %lu\n", current->name,
|
||||||
current->state, usec);
|
current->state, msec);
|
||||||
|
|
||||||
current->state = SLEEPING;
|
current->state = SLEEPING;
|
||||||
current->sleepHaveTimeouted = 0;
|
current->sleepHaveTimeouted = 0;
|
||||||
current->jiffiesSleeping = usecs_to_jiffies(usec);
|
current->jiffiesSleeping = msecs_to_jiffies(msec);
|
||||||
next = threadSelectNext();
|
next = threadSelectNext();
|
||||||
|
|
||||||
assert(next != current);
|
assert(next != current);
|
||||||
|
@ -83,7 +83,6 @@ int threadYield();
|
|||||||
int threadWait(struct thread *current, struct thread *next, unsigned long msec);
|
int threadWait(struct thread *current, struct thread *next, unsigned long msec);
|
||||||
int threadUnsched(struct thread *th);
|
int threadUnsched(struct thread *th);
|
||||||
int threadMsleep(unsigned long msec);
|
int threadMsleep(unsigned long msec);
|
||||||
int threadUsleep(unsigned long usec);
|
|
||||||
int threadOnJieffiesTick();
|
int threadOnJieffiesTick();
|
||||||
struct thread *getCurrentThread();
|
struct thread *getCurrentThread();
|
||||||
int threadAddThread(struct thread *th);
|
int threadAddThread(struct thread *th);
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#define SYSCALL_ID_MMAP 7
|
#define SYSCALL_ID_MMAP 7
|
||||||
#define SYSCALL_ID_MUNMAP 8
|
#define SYSCALL_ID_MUNMAP 8
|
||||||
#define SYSCALL_ID_NEW_THREAD 9
|
#define SYSCALL_ID_NEW_THREAD 9
|
||||||
#define SYSCALL_ID_USLEEP 10
|
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
int syscallExecute(int syscallId, const struct cpu_state *user_ctx);
|
int syscallExecute(int syscallId, const struct cpu_state *user_ctx);
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include "swintr.h"
|
#include "swintr.h"
|
||||||
#include "sys/mman.h"
|
#include "sys/mman.h"
|
||||||
#include "syscall.h"
|
#include "syscall.h"
|
||||||
#include "unistd.h"
|
|
||||||
|
|
||||||
int errno = 0;
|
int errno = 0;
|
||||||
int memcmp(const void *aptr, const void *bptr, size_t size)
|
int memcmp(const void *aptr, const void *bptr, size_t size)
|
||||||
@ -766,7 +765,3 @@ int new_thread(start_routine *func, void *arg, size_t stackSize)
|
|||||||
return syscall4(SYSCALL_ID_NEW_THREAD, (unsigned int)thread_runner, (unsigned int)func,
|
return syscall4(SYSCALL_ID_NEW_THREAD, (unsigned int)thread_runner, (unsigned int)func,
|
||||||
(unsigned int)arg, stackSize);
|
(unsigned int)arg, stackSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
int usleep(useconds_t usec) {
|
|
||||||
return syscall1(SYSCALL_ID_USLEEP, (unsigned int)usec);
|
|
||||||
}
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include "stddef.h"
|
#include "stddef.h"
|
||||||
#include "sys/mman.h"
|
#include "sys/mman.h"
|
||||||
#include "tiny.h"
|
#include "tiny.h"
|
||||||
#include "unistd.h"
|
|
||||||
|
|
||||||
int func_help()
|
int func_help()
|
||||||
{
|
{
|
||||||
@ -123,7 +122,6 @@ int func_munmap()
|
|||||||
static void *print_hello(void *arg) {
|
static void *print_hello(void *arg) {
|
||||||
(void)arg;
|
(void)arg;
|
||||||
printf("Hello World from thread\n");
|
printf("Hello World from thread\n");
|
||||||
usleep(100);
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
typedef unsigned int useconds_t;
|
|
||||||
int usleep(useconds_t usec);
|
|
Loading…
x
Reference in New Issue
Block a user