URL
https://opencores.org/ocsvn/plasma/plasma/trunk
Subversion Repositories plasma
Compare Revisions
- This comparison shows the changes necessary to convert path
/plasma/trunk/kernel
- from Rev 435 to Rev 436
- ↔ Reverse comparison
Rev 435 → Rev 436
/libc.c
61,6 → 61,20
return dstSave; |
} |
|
#ifdef STRNCAT_SIZE |
char *strncat_size(char *dst, const char *src, int sizeDst) |
{ |
int c=1; |
char *dstSave=dst; |
while(*dst) |
++dst; |
sizeDst -= dst - dstSave; |
while(--sizeDst > 0 && c) |
c = *dst++ = *src++; |
*dst = 0; |
return dstSave; |
} |
#endif |
|
int strcmp(const char *string1, const char *string2) |
{ |
183,7 → 197,7
|
|
static uint32 Rand1=0x1f2bcda3; |
unsigned int rand(void) |
int rand(void) |
{ |
Rand1 = 1664525 * Rand1 + 1013904223; //from D.E. Knuth and H.W. Lewis |
return Rand1 << 16 | Rand1 >> 16; |
/rtos_ex.c
11,6 → 11,7
* Support simulating multiple CPUs using symmetric multiprocessing. |
*--------------------------------------------------------------------*/ |
#include "plasma.h" |
#define NO_ELLIPSIS2 |
#include "rtos.h" |
|
/************** WIN32 Simulation Support *************/ |
40,7 → 41,15
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)OS_Start, NULL, 0, &ThreadId[i]); |
} |
#endif //OS_CPU_COUNT > 1 |
#else //NWIN32 |
#include <unistd.h> |
#define kbhit() 1 |
#define getch getchar |
#define putch putchar |
#define Sleep(X) usleep(X*1000) |
#endif //WIN32 |
|
|
static uint32 Memory[8]; |
|
//Simulates device register memory reads |
108,9 → 117,7
putchar(*ptr++); |
} |
|
#endif //WIN32 |
|
|
#if OS_CPU_COUNT > 1 |
static volatile uint8 SpinLockArray[OS_CPU_COUNT]; |
/******************************************/ |
/rtos.c
28,7 → 28,9
|
/*************** Structures ***************/ |
#ifdef WIN32 |
#define setjmp _setjmp |
#ifndef setjmp |
#define setjmp _setjmp |
#endif |
//x86 registers |
typedef struct jmp_buf2 { |
uint32 Ebp, Ebx, Edi, Esi, sp, pc, extra[10]; |
286,7 → 288,7
/***************** Thread *****************/ |
/******************************************/ |
//Linked list of threads sorted by priority |
//The listed list is either ThreadHead (ready to run threads not including |
//The linked list is either ThreadHead (ready to run threads not including |
//the currently running thread) or a list of threads waiting on a semaphore. |
//Must be called with interrupts disabled |
static void OS_ThreadPriorityInsert(OS_Thread_t **head, OS_Thread_t *thread) |
/math.c
12,6 → 12,7
* IEEE_fp = sign(1) | exponent(8) | fraction(23) |
* cos(x)=1-x^2/2!+x^4/4!-x^6/6!+... |
* exp(x)=1+x+x^2/2!+x^3/3!+... |
* e^x=2^y; ln2(e^x)=ln2(2^y); ln(e^x)/ln(2)=y; x/ln(2)=y; e^x=2^(x/ln(2)) |
* ln(1+x)=x-x^2/2+x^3/3-x^4/4+... |
* atan(x)=x-x^3/3+x^5/5-x^7/7+... |
* pow(x,y)=exp(y*ln(x)) |
18,6 → 19,7
* x=tan(a+b)=(tan(a)+tan(b))/(1-tan(a)*tan(b)) |
* atan(x)=b+atan((x-atan(b))/(1+x*atan(b))) |
* ln(a*x)=ln(a)+ln(x); ln(x^n)=n*ln(x) |
* sqrt(x)=sqrt(f*2^e)=sqrt(f)*2^(e/2) |
*--------------------------------------------------------------------*/ |
#include "rtos.h" |
|
354,8 → 356,8
rad = FP_Sub(rad, PI2); |
while(FP_Cmp(rad, (float)0.0) < 0) |
rad = FP_Add(rad, PI2); |
answer = 1.0; |
sign = 1.0; |
answer = (float)1.0; |
sign = (float)1.0; |
if(FP_Cmp(rad, PI) >= 0) |
{ |
rad = FP_Sub(rad, PI); |
367,8 → 369,8
sign = FP_Neg(sign); |
} |
x2 = FP_Mult(rad, rad); |
top = 1.0; |
bottom = 1.0; |
top = (float)1.0; |
bottom = (float)1.0; |
for(n = 2; n < 12; n += 2) |
{ |
top = FP_Mult(top, FP_Neg(x2)); |
454,7 → 456,7
float answer, top, bottom, mult; |
int n; |
|
mult = 1.0; |
mult = (float)1.0; |
while(FP_Cmp(x, (float)2.0) > 0) |
{ |
mult = FP_Mult(mult, e2); |
467,7 → 469,7
} |
answer = FP_Add((float)1.0, x); |
top = x; |
bottom = 1.0; |
bottom = (float)1.0; |
for(n = 2; n < 15; ++n) |
{ |
top = FP_Mult(top, x); |
483,25 → 485,25
const float log_2=(float)0.69314718; /*log(2.0)*/ |
int n; |
float answer, top, add; |
add = 0.0; |
while(FP_Cmp(x, 16.0) > 0) |
add = (float)0.0; |
while(FP_Cmp(x, (float)16.0) > 0) |
{ |
x = FP_Mult(x, (float)0.0625); |
add = FP_Add(add, (float)(log_2 * 4)); |
} |
while(FP_Cmp(x, 1.5) > 0) |
while(FP_Cmp(x, (float)1.5) > 0) |
{ |
x = FP_Mult(x, 0.5); |
x = FP_Mult(x, (float)0.5); |
add = FP_Add(add, log_2); |
} |
while(FP_Cmp(x, 0.5) < 0) |
{ |
x = FP_Mult(x, 2.0); |
x = FP_Mult(x, (float)2.0); |
add = FP_Sub(add, log_2); |
} |
x = FP_Sub(x, 1.0); |
answer = 0.0; |
top = -1.0; |
x = FP_Sub(x, (float)1.0); |
answer = (float)0.0; |
top = (float)-1.0; |
for(n = 1; n < 14; ++n) |
{ |
top = FP_Mult(top, FP_Neg(x)); |
/rtos.h
30,6 → 30,7
#define _CRT_SECURE_NO_WARNINGS 1 |
#include <stdio.h> |
#include <assert.h> |
#include <setjmp.h> |
#define _LIBC |
uint32 MemoryRead(uint32 Address); |
void MemoryWrite(uint32 Address, uint32 Value); |
92,12 → 93,16
void *memset(void *dst, int c, unsigned long bytes); |
int abs(int n); |
int atoi(const char *s); |
unsigned int rand(void); |
int rand(void); |
void srand(unsigned int seed); |
long strtol(const char *s, char **end, int base); |
char *itoa(int num, char *dst, int base); |
|
#ifndef NO_ELLIPSIS |
typedef char* va_list; |
#define va_start(AP,P) (AP=(char*)&(P)+sizeof(char*)) |
#define va_arg(AP,T) (*(T*)((AP+=sizeof(T))-sizeof(T))) |
#define va_end(AP) |
int sprintf(char *s, const char *format, ...); |
int sscanf(const char *s, const char *format, ...); |
#endif |
105,8 → 110,8
#define printf UartPrintf |
#ifndef _LIBC |
#define assert(A) if((A)==0){OS_Assert();UartPrintfCritical("\r\nAssert %s:%d\r\n", __FILE__, __LINE__);} |
#define scanf UartScanf |
#define NULL (void*)0 |
#define scanf UartScanf |
#define NULL (void*)0 |
#else |
#define UartPrintfCritical UartPrintf |
#endif //_LIBC |
146,11 → 151,13
#endif |
|
/***************** Assembly **************/ |
#ifndef WIN32 |
typedef uint32 jmp_buf[20]; |
extern int setjmp(jmp_buf env); |
extern void longjmp(jmp_buf env, int val); |
#endif |
extern uint32 OS_AsmInterruptEnable(uint32 state); |
extern void OS_AsmInterruptInit(void); |
extern int setjmp(jmp_buf env); |
extern void longjmp(jmp_buf env, int val); |
extern uint32 OS_AsmMult(uint32 a, uint32 b, unsigned long *hi); |
extern void *OS_Syscall(uint32 value); |
|
/makefile
27,7 → 27,7
|
# Customized for Linux |
# See the GNU GCC tab on the Opencores Plasma page |
CC_X86 = gcc -Wall -O -g -I../tools |
CC_X86 = gcc -Wall -O -g -I../tools -m32 |
CP = cp |
RM = rm -rf |
DWIN32 = |