git.ucc.asn.au
/
tpg
/
acess2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
28eafc7
)
Kernel - General fixing after ARM7 changes
author
John Hodge
<
[email protected]
>
Mon, 22 Aug 2011 07:16:55 +0000
(15:16 +0800)
committer
John Hodge
<
[email protected]
>
Mon, 22 Aug 2011 07:16:55 +0000
(15:16 +0800)
- Also fixed x86_64 crt0
CleanAllArch
patch
|
blob
|
history
Kernel/arch/arm7/include/lock.h
patch
|
blob
|
history
Kernel/arch/arm7/start.s
patch
|
blob
|
history
Kernel/arch/x86/include/proc.h
patch
|
blob
|
history
Kernel/arch/x86/proc.c
patch
|
blob
|
history
Kernel/arch/x86_64/include/proc.h
patch
|
blob
|
history
Kernel/arch/x86_64/proc.c
patch
|
blob
|
history
Makefile
patch
|
blob
|
history
Usermode/Libraries/crt0.o_src/crt0.asm
patch
|
blob
|
history
Usermode/Libraries/crt0.o_src/crt0.x86_64.asm
patch
|
blob
|
history
diff --git
a/CleanAllArch
b/CleanAllArch
index
5ccf811
..
1e8c18b
100755
(executable)
--- a/
CleanAllArch
+++ b/
CleanAllArch
@@
-1,2
+1,2
@@
#!/bin/sh
#!/bin/sh
-for a in i386
i486 i586 x86_64 arm
host; do echo $a; ARCH=$a make clean; done
+for a in i386
x86_64 arm7
host; do echo $a; ARCH=$a make clean; done
diff --git
a/Kernel/arch/arm7/include/lock.h
b/Kernel/arch/arm7/include/lock.h
index
9b289d1
..
e270145
100644
(file)
--- a/
Kernel/arch/arm7/include/lock.h
+++ b/
Kernel/arch/arm7/include/lock.h
@@
-26,6
+26,14
@@
static inline int CPU_HAS_LOCK(struct sShortSpinlock *Lock)
static inline int SHORTLOCK(struct sShortSpinlock *Lock)
{
static inline int SHORTLOCK(struct sShortSpinlock *Lock)
{
+ #if 0
+ while( __sync_lock_test_and_set( &Lock->Lock, 1 ) == 1 );
+ #endif
+ #if 1
+ while( Lock->Lock ) ;
+ Lock->Lock = 1;
+ #endif
+ #if 0
// Shamelessly copied from linux (/arch/arm/include/asm/spinlock.h) until I can fix stuff
Uint tmp;
__asm__ __volatile__ (
// Shamelessly copied from linux (/arch/arm/include/asm/spinlock.h) until I can fix stuff
Uint tmp;
__asm__ __volatile__ (
@@
-38,6
+46,7
@@
static inline int SHORTLOCK(struct sShortSpinlock *Lock)
: "r" (&Lock->Lock), "r" (1)
: "cc" // Condition codes clobbered
);
: "r" (&Lock->Lock), "r" (1)
: "cc" // Condition codes clobbered
);
+ #endif
return 1;
}
return 1;
}
diff --git
a/Kernel/arch/arm7/start.s
b/Kernel/arch/arm7/start.s
index
1897ecd
..
d1a55da
100644
(file)
--- a/
Kernel/arch/arm7/start.s
+++ b/
Kernel/arch/arm7/start.s
@@
-14,9
+14,20
@@
interrupt_vector_table:
.globl _start
_start:
.globl _start
_start:
+ ldr r0, _ptr_kerneltable0
+ mcr p15, 0, r0, c2, c0, 1 @ Set TTBR1 to r0
+ mov r0, #1
+ mcr p15, 0, r0, c2, c0, 2 @ Set TTCR to 1 (50/50 split)
+
+ mrc p15, 0, r0, c1, c0, 0
+ orr r0, r0, #1
+ mcr p15, 0, r0, c1, c0, 0
+
ldr sp, =stack+0x10000 @ Set up stack
bl kmain
1: b 1b @ Infinite loop
ldr sp, =stack+0x10000 @ Set up stack
bl kmain
1: b 1b @ Infinite loop
+_ptr_kerneltable0:
+ .long kernel_table0-0x80000000
SyscallHandler:
SyscallHandler:
diff --git
a/Kernel/arch/x86/include/proc.h
b/Kernel/arch/x86/include/proc.h
index
e31c76d
..
e449a0f
100644
(file)
--- a/
Kernel/arch/x86/include/proc.h
+++ b/
Kernel/arch/x86/include/proc.h
@@
-23,8
+23,4
@@
typedef struct sTSS {
Uint16 Resvd, IOPB; // IO Permissions Bitmap
} __attribute__((packed)) tTSS;
Uint16 Resvd, IOPB; // IO Permissions Bitmap
} __attribute__((packed)) tTSS;
-// === FUNCTIONS ===
-extern void Proc_Start(void);
-extern int Proc_Clone(Uint *Err, Uint Flags);
-
#endif
#endif
diff --git
a/Kernel/arch/x86/proc.c
b/Kernel/arch/x86/proc.c
index
ceb80ad
..
8cff256
100644
(file)
--- a/
Kernel/arch/x86/proc.c
+++ b/
Kernel/arch/x86/proc.c
@@
-11,6
+11,7
@@
#if USE_MP
# include <mp.h>
#endif
#if USE_MP
# include <mp.h>
#endif
+#include <hal_proc.h>
// === FLAGS ===
#define DEBUG_TRACE_SWITCH 0
// === FLAGS ===
#define DEBUG_TRACE_SWITCH 0
@@
-46,7
+47,6
@@
extern void APWait(void); // 16-bit AP pause code
extern void APStartup(void); // 16-bit AP startup code
extern Uint GetEIP(void); // start.asm
extern Uint GetEIP_Sched(void); // proc.asm
extern void APStartup(void); // 16-bit AP startup code
extern Uint GetEIP(void); // start.asm
extern Uint GetEIP_Sched(void); // proc.asm
-extern int GetCPUNum(void); // start.asm
extern Uint32 gaInitPageDir[1024]; // start.asm
extern char Kernel_Stack_Top[];
extern tShortSpinlock glThreadListLock;
extern Uint32 gaInitPageDir[1024]; // start.asm
extern char Kernel_Stack_Top[];
extern tShortSpinlock glThreadListLock;
@@
-61,7
+61,7
@@
extern void IRQCommon_handled; // IRQCommon call return location
extern void GetEIP_Sched_ret; // GetEIP call return location
// === PROTOTYPES ===
extern void GetEIP_Sched_ret; // GetEIP call return location
// === PROTOTYPES ===
-
void
ArchThreads_Init(void);
+
//void
ArchThreads_Init(void);
#if USE_MP
void MP_StartAP(int CPU);
void MP_SendIPI(Uint8 APICID, int Vector, int DeliveryMode);
#if USE_MP
void MP_StartAP(int CPU);
void MP_SendIPI(Uint8 APICID, int Vector, int DeliveryMode);
@@
-71,11
+71,11
@@
void MP_SendIPI(Uint8 APICID, int Vector, int DeliveryMode);
void Proc_ChangeStack(void);
// int Proc_Clone(Uint *Err, Uint Flags);
Uint Proc_MakeUserStack(void);
void Proc_ChangeStack(void);
// int Proc_Clone(Uint *Err, Uint Flags);
Uint Proc_MakeUserStack(void);
-
void
Proc_StartUser(Uint Entrypoint, Uint *Bases, int ArgC, char **ArgV, char **EnvP, int DataSize);
+
//void
Proc_StartUser(Uint Entrypoint, Uint *Bases, int ArgC, char **ArgV, char **EnvP, int DataSize);
void Proc_StartProcess(Uint16 SS, Uint Stack, Uint Flags, Uint16 CS, Uint IP);
int Proc_Demote(Uint *Err, int Dest, tRegs *Regs);
void Proc_StartProcess(Uint16 SS, Uint Stack, Uint Flags, Uint16 CS, Uint IP);
int Proc_Demote(Uint *Err, int Dest, tRegs *Regs);
-
void
Proc_CallFaultHandler(tThread *Thread);
-
void
Proc_DumpThreadCPUState(tThread *Thread);
+
//void
Proc_CallFaultHandler(tThread *Thread);
+
//void
Proc_DumpThreadCPUState(tThread *Thread);
void Proc_Scheduler(int CPU);
// === GLOBALS ===
void Proc_Scheduler(int CPU);
// === GLOBALS ===
@@
-471,7
+471,7
@@
void Proc_Start(void)
while( giNumInitingCPUs ) __asm__ __volatile__ ("hlt");
#else
// Create Idle Task
while( giNumInitingCPUs ) __asm__ __volatile__ ("hlt");
#else
// Create Idle Task
- if(Proc_Clone(0
, 0
) == 0)
+ if(Proc_Clone(0) == 0)
{
gpIdleThread = Proc_GetCurThread();
gpIdleThread->ThreadName = strdup("Idle Thread");
{
gpIdleThread = Proc_GetCurThread();
gpIdleThread->ThreadName = strdup("Idle Thread");
@@
-557,7
+557,7
@@
void Proc_ChangeStack(void)
* \fn int Proc_Clone(Uint *Err, Uint Flags)
* \brief Clone the current process
*/
* \fn int Proc_Clone(Uint *Err, Uint Flags)
* \brief Clone the current process
*/
-int Proc_Clone(Uint
*Err, Uint
Flags)
+int Proc_Clone(Uint Flags)
{
tThread *newThread;
tThread *cur = Proc_GetCurThread();
{
tThread *newThread;
tThread *cur = Proc_GetCurThread();
@@
-566,7
+566,7
@@
int Proc_Clone(Uint *Err, Uint Flags)
__asm__ __volatile__ ("mov %%esp, %0": "=r"(esp));
__asm__ __volatile__ ("mov %%ebp, %0": "=r"(ebp));
__asm__ __volatile__ ("mov %%esp, %0": "=r"(esp));
__asm__ __volatile__ ("mov %%ebp, %0": "=r"(ebp));
- newThread = Threads_CloneTCB(
Err
, Flags);
+ newThread = Threads_CloneTCB(
NULL
, Flags);
if(!newThread) return -1;
// Initialise Memory Space (New Addr space or kernel stack)
if(!newThread) return -1;
// Initialise Memory Space (New Addr space or kernel stack)
diff --git
a/Kernel/arch/x86_64/include/proc.h
b/Kernel/arch/x86_64/include/proc.h
index
93926f7
..
2913f73
100644
(file)
--- a/
Kernel/arch/x86_64/include/proc.h
+++ b/
Kernel/arch/x86_64/include/proc.h
@@
-45,9
+45,5
@@
typedef struct sTaskState
// === CONSTANTS ===
#define KERNEL_STACK_SIZE 0x10000 // 64 KiB
// === CONSTANTS ===
#define KERNEL_STACK_SIZE 0x10000 // 64 KiB
-// === FUNCTIONS ===
-extern void Proc_Start(void);
-extern int Proc_Clone(Uint *Err, Uint Flags);
-
#endif
#endif
diff --git
a/Kernel/arch/x86_64/proc.c
b/Kernel/arch/x86_64/proc.c
index
ed2b684
..
31dd80e
100644
(file)
--- a/
Kernel/arch/x86_64/proc.c
+++ b/
Kernel/arch/x86_64/proc.c
@@
-13,6
+13,7
@@
# include <mp.h>
#endif
#include <arch_config.h>
# include <mp.h>
#endif
#include <arch_config.h>
+#include <hal_proc.h>
// === FLAGS ===
#define DEBUG_TRACE_SWITCH 0
// === FLAGS ===
#define DEBUG_TRACE_SWITCH 0
@@
-45,11
+46,10
@@
extern int giNumActiveThreads;
extern tThread gThreadZero;
extern void Threads_Dump(void);
extern void Proc_ReturnToUser(void);
extern tThread gThreadZero;
extern void Threads_Dump(void);
extern void Proc_ReturnToUser(void);
-extern int GetCPUNum(void);
extern void Time_UpdateTimestamp(void);
// === PROTOTYPES ===
extern void Time_UpdateTimestamp(void);
// === PROTOTYPES ===
-
void
ArchThreads_Init(void);
+
//void
ArchThreads_Init(void);
#if USE_MP
void MP_StartAP(int CPU);
void MP_SendIPI(Uint8 APICID, int Vector, int DeliveryMode);
#if USE_MP
void MP_StartAP(int CPU);
void MP_SendIPI(Uint8 APICID, int Vector, int DeliveryMode);
@@
-60,11
+60,11
@@
void Proc_ChangeStack(void);
// int Proc_Clone(Uint *Err, Uint Flags);
// int Proc_SpawnWorker(void);
Uint Proc_MakeUserStack(void);
// int Proc_Clone(Uint *Err, Uint Flags);
// int Proc_SpawnWorker(void);
Uint Proc_MakeUserStack(void);
-
void
Proc_StartUser(Uint Entrypoint, Uint *Bases, int ArgC, char **ArgV, char **EnvP, int DataSize);
+
//void
Proc_StartUser(Uint Entrypoint, Uint *Bases, int ArgC, char **ArgV, char **EnvP, int DataSize);
void Proc_StartProcess(Uint16 SS, Uint Stack, Uint Flags, Uint16 CS, Uint IP);
int Proc_Demote(Uint *Err, int Dest, tRegs *Regs);
void Proc_StartProcess(Uint16 SS, Uint Stack, Uint Flags, Uint16 CS, Uint IP);
int Proc_Demote(Uint *Err, int Dest, tRegs *Regs);
-
void
Proc_CallFaultHandler(tThread *Thread);
-
void
Proc_DumpThreadCPUState(tThread *Thread);
+
//void
Proc_CallFaultHandler(tThread *Thread);
+
//void
Proc_DumpThreadCPUState(tThread *Thread);
void Proc_Scheduler(int CPU);
// === GLOBALS ===
void Proc_Scheduler(int CPU);
// === GLOBALS ===
@@
-391,7
+391,7
@@
void Proc_Start(void)
while( giNumInitingCPUs ) __asm__ __volatile__ ("hlt");
#else
// Create Idle Task
while( giNumInitingCPUs ) __asm__ __volatile__ ("hlt");
#else
// Create Idle Task
- if(Proc_Clone(0
, 0
) == 0)
+ if(Proc_Clone(0) == 0)
{
gaCPUs[0].IdleThread = Proc_GetCurThread();
gaCPUs[0].IdleThread->ThreadName = (char*)"Idle Thread";
{
gaCPUs[0].IdleThread = Proc_GetCurThread();
gaCPUs[0].IdleThread->ThreadName = (char*)"Idle Thread";
@@
-477,10
+477,10
@@
void Proc_ChangeStack(void)
}
/**
}
/**
- * \fn int Proc_Clone(Uint
*Err, Uint
Flags)
+ * \fn int Proc_Clone(Uint Flags)
* \brief Clone the current process
*/
* \brief Clone the current process
*/
-int Proc_Clone(Uint
*Err, Uint
Flags)
+int Proc_Clone(Uint Flags)
{
tThread *newThread;
tThread *cur = Proc_GetCurThread();
{
tThread *newThread;
tThread *cur = Proc_GetCurThread();
@@
-489,7
+489,7
@@
int Proc_Clone(Uint *Err, Uint Flags)
__asm__ __volatile__ ("mov %%rsp, %0": "=r"(rsp));
__asm__ __volatile__ ("mov %%rbp, %0": "=r"(rbp));
__asm__ __volatile__ ("mov %%rsp, %0": "=r"(rsp));
__asm__ __volatile__ ("mov %%rbp, %0": "=r"(rbp));
- newThread = Threads_CloneTCB(
Err
, Flags);
+ newThread = Threads_CloneTCB(
NULL
, Flags);
if(!newThread) return -1;
Log("Proc_Clone: newThread = %p", newThread);
if(!newThread) return -1;
Log("Proc_Clone: newThread = %p", newThread);
diff --git
a/Makefile
b/Makefile
index
f7f5928
..
4fca6d5
100644
(file)
--- a/
Makefile
+++ b/
Makefile
@@
-15,7
+15,8
@@
USRLIBS += libreadline.so libnet.so liburi.so
USRLIBS += libaxwin2.so libimage_sif.so
USRAPPS := init login CLIShell cat ls mount
USRLIBS += libaxwin2.so libimage_sif.so
USRAPPS := init login CLIShell cat ls mount
-USRAPPS += bomb pcidump
+USRAPPS += bomb
+#USRAPPS += pcidump
USRAPPS += ifconfig ping telnet irc
USRAPPS += axwin2
USRAPPS += ifconfig ping telnet irc
USRAPPS += axwin2
diff --git
a/Usermode/Libraries/crt0.o_src/crt0.asm
b/Usermode/Libraries/crt0.o_src/crt0.asm
index
81400c5
..
531a378
100644
(file)
--- a/
Usermode/Libraries/crt0.o_src/crt0.asm
+++ b/
Usermode/Libraries/crt0.o_src/crt0.asm
@@
-19,7
+19,7
@@
start:
mov eax, [_crt0_exit_handler]
test eax, eax
jz .exit
mov eax, [_crt0_exit_handler]
test eax, eax
jz .exit
- call
[eax]
+ call
eax
.exit:
call _exit
.exit:
call _exit
diff --git
a/Usermode/Libraries/crt0.o_src/crt0.x86_64.asm
b/Usermode/Libraries/crt0.o_src/crt0.x86_64.asm
index
56fa980
..
fb0115d
100644
(file)
--- a/
Usermode/Libraries/crt0.o_src/crt0.x86_64.asm
+++ b/
Usermode/Libraries/crt0.o_src/crt0.x86_64.asm
@@
-15,5
+15,17
@@
_start:
start:
call main
push rax
start:
call main
push rax
+
+ mov rax, [_crt0_exit_handler]
+ test rax, rax
+ jz .exit
+ call rax
+
+.exit:
call _exit
jmp $ ; This should never be reached
call _exit
jmp $ ; This should never be reached
+
+[section .bss]
+[global _crt0_exit_handler]
+_crt0_exit_handler:
+ resq 1
UCC
git Repository :: git.ucc.asn.au