#include "util.h" // dprintf
#include "bregs.h" // CR0_PE
-static inline u32 getcr0() {
+static inline u32 getcr0(void) {
u32 cr0;
asm("movl %%cr0, %0" : "=r"(cr0));
return cr0;
" addl %0, %%esp\n"
" movl %%ss, %0\n"
- // Transition to 32bit mode, call yield_preempt, return to 16bit
+ // Transition to 32bit mode, call func, return to 16bit
" pushl $(" __stringify(BUILD_BIOS_ADDR) " + 1f)\n"
" jmp transition32\n"
" .code32\n"
int VAR16VISIBLE CanPreempt;
void
-thread_setup()
+thread_setup(void)
{
MainThread.next = &MainThread;
MainThread.stackpos = NULL;
// Return the 'struct thread_info' for the currently running thread.
struct thread_info *
-getCurThread()
+getCurThread(void)
{
u32 esp = getesp();
if (esp <= BUILD_STACK_ADDR)
switch_next(struct thread_info *cur)
{
struct thread_info *next = cur->next;
+ if (cur == next)
+ // Nothing to do.
+ return;
asm volatile(
" pushl $1f\n" // store return pc
" pushl %%ebp\n" // backup %ebp
// Briefly permit irqs to occur.
void
-yield()
+yield(void)
{
- if (MODE16 || !CONFIG_THREADS) {
+ if (MODESEGMENT || !CONFIG_THREADS) {
// Just directly check irqs.
check_irqs();
return;
void
run_thread(void (*func)(void*), void *data)
{
- ASSERT32();
+ ASSERT32FLAT();
if (! CONFIG_THREADS)
goto fail;
struct thread_info *thread;
// Wait for all threads (other than the main thread) to complete.
void
-wait_threads()
+wait_threads(void)
{
- ASSERT32();
+ ASSERT32FLAT();
if (! CONFIG_THREADS)
return;
while (MainThread.next != &MainThread)
// Turn on RTC irqs and arrange for them to check the 32bit threads.
void
-start_preempt()
+start_preempt(void)
{
if (! CONFIG_THREADS || ! CONFIG_THREAD_OPTIONROMS)
return;
// Turn off RTC irqs / stop checking for thread execution.
void
-finish_preempt()
+finish_preempt(void)
{
if (! CONFIG_THREADS || ! CONFIG_THREAD_OPTIONROMS)
return;
dprintf(1, "Done preempt - %d checks\n", PreemptCount);
}
-extern void yield_preempt();
-#if !MODE16
+extern void yield_preempt(void);
+#if MODESEGMENT == 0
// Try to execute 32bit threads.
-void VISIBLE32
-yield_preempt()
+void VISIBLE32FLAT
+yield_preempt(void)
{
PreemptCount++;
switch_next(&MainThread);
// 16bit code that checks if threads are pending and executes them if so.
void
-check_preempt()
+check_preempt(void)
{
if (! CONFIG_THREADS || ! CONFIG_THREAD_OPTIONROMS
|| !GET_GLOBAL(CanPreempt)