OpenCores
URL https://opencores.org/ocsvn/plasma/plasma/trunk

Subversion Repositories plasma

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /plasma/trunk
    from Rev 424 to Rev 425
    Reverse comparison

Rev 424 → Rev 425

/kernel/libc.c
249,7 → 249,7
negate = 1;
}
text[16] = 0;
for(place = 15; place >= 0; --place)
for(place = 15; place > 0; --place)
{
digit = (unsigned int)num % (unsigned int)base;
if(num == 0 && place < 15 && base == 10 && negate)
277,7 → 277,7
{
int argv[8];
int argc=0, width, length;
char f, text[20], fill;
char f=0, prev, text[20], fill;
 
argv[0] = arg0; argv[1] = arg1; argv[2] = arg2; argv[3] = arg3;
argv[4] = arg4; argv[5] = arg5; argv[6] = arg6; argv[7] = arg7;
284,6 → 284,7
 
for(;;)
{
prev = f;
f = *format++;
if(f == 0)
return argc;
342,11 → 343,9
}
else
{
if(f == '\n')
if(f == '\n' && prev != '\r')
*s++ = '\r';
*s++ = f;
if(f == '\r' && *format == '\n')
*s++ = *format++;
}
*s = 0;
}
580,6 → 579,7
break;
}
out->tm_year = year + 80;
out->tm_yday = seconds / SEC_PER_DAY;
isLeapYear = IsLeapYear(1980 + year);
for(month = 0; ; ++month)
{
591,7 → 591,6
}
out->tm_mon = month;
out->tm_mday = seconds / SEC_PER_DAY;
out->tm_yday = DaysUntilMonth[month] + out->tm_mday;
seconds -= out->tm_mday * SEC_PER_DAY;
++out->tm_mday;
out->tm_hour = seconds / (60 * 60);
/kernel/filesys.c
443,7 → 443,7
{
if(name[0] == '/')
++name;
for(length = 0; length < FILE_NAME_SIZE; ++length)
for(length = 0; length < FILE_NAME_SIZE-1; ++length)
{
if(name[length] == 0 || name[length] == '/')
break;
657,6 → 657,8
int rc;
 
dir = OS_fopen(name, "r");
if(dir == NULL)
return 0;
for(;;)
{
rc = OS_fdir(dir, (char*)&fileEntry);
684,6 → 686,8
int i, j;
 
buf = (char*)malloc(5000);
if(buf == NULL)
return -1;
memset(buf, 0, 5000);
for(count = 0; count < 4000; ++count)
buf[count] = (char)('A' + (count % 26));
690,10 → 694,14
OS_fmkdir("dir");
OS_fmkdir("/dir/subdir");
file = OS_fopen("/dir/subdir/test.txt", "w");
if(file == NULL)
return -1;
count = OS_fwrite(buf, 1, 4000, file);
OS_fclose(file);
memset(buf, 0, 5000);
file = OS_fopen("/dir/subdir/test.txt", "r");
if(file == NULL)
return -1;
count = OS_fread(buf, 1, 5000, file);
OS_fclose(file);
printf("(%s)\n", buf);
708,9 → 716,12
{
sprintf(buf, "/dir%d/file%d%d", i, i, j);
file = OS_fopen(buf, "w");
sprintf(buf, "i=%d j=%d", i, j);
OS_fwrite(buf, 1, 8, file);
OS_fclose(file);
if(file)
{
sprintf(buf, "i=%d j=%d", i, j);
OS_fwrite(buf, 1, 8, file);
OS_fclose(file);
}
}
}
 
/kernel/tcpip.c
142,6 → 142,8
#define PING_SEQUENCE 40 //2
#define PING_DATA 44
 
enum {FRAME_FREE=0, FRAME_ACQUIRED=1, FRAME_IN_LIST};
 
static void IPClose2(IPSocket *Socket);
static void IPArp(unsigned char ipAddress[4]);
 
222,8 → 224,8
OS_CriticalEnd(state);
if(frame)
{
assert(frame->state == 0);
frame->state = 1;
assert(frame->state == FRAME_FREE);
frame->state = FRAME_ACQUIRED;
}
return frame;
}
233,8 → 235,8
{
uint32 state;
 
assert(frame->state == 1);
frame->state = 0;
assert(frame->state == FRAME_ACQUIRED);
frame->state = FRAME_FREE;
state = OS_CriticalBegin();
frame->next = FrameFreeHead;
FrameFreeHead = frame;
245,8 → 247,8
 
static void FrameInsert(IPFrame **head, IPFrame **tail, IPFrame *frame)
{
assert(frame->state == 1);
frame->state = 2;
assert(frame->state == FRAME_ACQUIRED);
frame->state = FRAME_IN_LIST;
OS_MutexPend(IPMutex);
frame->prev = NULL;
frame->next = *head;
261,13 → 263,13
 
static void FrameRemove(IPFrame **head, IPFrame **tail, IPFrame *frame)
{
assert(frame->state == 2);
if(frame->state != 2)
assert(frame->state == FRAME_IN_LIST);
if(frame->state != FRAME_IN_LIST)
{
printf("frame->state=%d\n", frame->state);
return;
}
frame->state = 1;
frame->state = FRAME_ACQUIRED;
if(frame->prev)
frame->prev->next = frame->next;
else
719,6 → 721,7
memcpy(socketNew, socket, sizeof(IPSocket));
socketNew->state = IP_TCP;
socketNew->timeout = SOCKET_TIMEOUT;
socketNew->timeoutReset = SOCKET_TIMEOUT * 6;
socketNew->ack = seq;
socketNew->ackProcessed = seq + 1;
socketNew->seq = socketNew->ack + 0x12345678;
1218,13 → 1221,16
FrameSendFunc = frameSendFunction;
IPMutex = OS_MutexCreate("IPSem");
IPMQueue = OS_MQueueCreate("IPMQ", FRAME_COUNT*2, 32);
frame = (IPFrame*)malloc(sizeof(IPFrame) * FRAME_COUNT);
if(frame == NULL)
return;
memset(frame, 0, sizeof(IPFrame) * FRAME_COUNT);
for(i = 0; i < FRAME_COUNT; ++i)
{
frame = (IPFrame*)malloc(sizeof(IPFrame));
memset(frame, 0, sizeof(IPFrame));
frame->next = FrameFreeHead;
frame->prev = NULL;
FrameFreeHead = frame;
++frame;
}
FrameFreeCount = FRAME_COUNT;
#ifndef WIN32
1414,9 → 1420,9
if(socket->seq - socket->seqReceived >= SEND_WINDOW)
{
//printf("l(%d,%d,%d) ", socket->seq - socket->seqReceived, socket->seq, socket->seqReceived);
if(self != IPThread && ++tries < 200)
if(self != IPThread && ++tries < 20)
{
OS_ThreadSleep(1);
OS_ThreadSleep(10);
continue;
}
}
1428,16 → 1434,19
if(socket->frameSend == NULL)
{
//printf("L");
if(self == IPThread || ++tries > 200)
if(self == IPThread || ++tries > 40)
break;
else
OS_ThreadSleep(1);
OS_ThreadSleep(10);
}
}
frameOut = socket->frameSend;
offset = socket->sendOffset;
if(frameOut == NULL)
{
printf("X");
break;
}
packetOut = frameOut->packet;
 
if(socket->state == IP_PING)
1771,6 → 1780,8
IPSocket *socket;
 
socket = IPOpen(IP_MODE_UDP, ipAddressDns, DNS_PORT, DnsCallback);
if(socket == NULL)
return;
memset(buf, 0, sizeof(buf));
buf[DNS_ID+1] = 1;
buf[DNS_FLAGS] = 1;
/kernel/netutil.c
87,10 → 87,11
int bytes;
int ip0, ip1, ip2, ip3, port0, port1;
IPSocket *socketOut;
FtpdInfo *info = (FtpdInfo*)socket->userPtr;
FtpdInfo *info;
 
if(socket == NULL)
return;
info = (FtpdInfo*)socket->userPtr;
bytes = IPRead(socket, buf, sizeof(buf)-1);
buf[bytes] = 0;
//printf("(%s)\n", buf);
283,9 → 284,13
info->state = 0;
info->port = 2000;
socketTransfer = IPOpen(IP_MODE_TCP, 0, info->port, FtpCallbackTransfer);
if(socketTransfer == NULL)
return NULL;
socketTransfer->userPtr = info;
socketTransfer->userFunc = callback;
socket = IPOpen(IP_MODE_TCP, ip, 21, FtpCallback);
if(socket == NULL)
return NULL;
socket->userPtr = info;
socket->userFunc = callback;
ptr = socket->headerSend;
391,6 → 396,8
uint8 buf[512+4];
int bytes;
socket = IPOpen(IP_MODE_UDP, ip, 69, TftpCallback);
if(socket == NULL)
return NULL;
socket->userPtr = buffer;
socket->userData = size;
socket->userFunc = callback;
531,13 → 538,14
int bytes, i, k, found, rc;
char *ptr, *command = (char*)socket->userPtr;
char command2[COMMAND_BUFFER_SIZE];
char *argvStorage[12], **argv = argvStorage+2;
char *argv[10];
 
if(socket->state > IP_TCP)
return;
for(;;)
{
bytes = IPRead(socket, bufIn, sizeof(bufIn)-1);
memset(bufIn, 0, sizeof(bufIn));
bytes = IPRead(socket, bufIn, sizeof(bufIn)-4);
if(command == NULL)
{
socket->userPtr = command = (char*)malloc(COMMAND_BUFFER_SIZE);
592,7 → 600,7
}
 
//Check for file in or out
for(k = 1; k < 10; ++k)
for(k = 1; k < 9; ++k)
{
if(argv[k][0] == '>') //stdout to file?
{
862,7 → 870,7
}
funcPtr = NULL;
OS_CriticalBegin();
funcPtr(NULL);
funcPtr(NULL); //jump to address 0
}
 
 
986,7 → 994,7
UartPrintfCritical(".");
FlashErase(bytes);
}
funcPtr(NULL);
funcPtr(NULL); //jump to address 0
}
#endif
 
1040,6 → 1048,8
(uint8)(ip >> 24), (uint8)(ip >> 16), (uint8)(ip >> 8), (uint8)ip);
IPPrintf(socketTelnet, buf);
socketPing = IPOpen(IP_MODE_PING, ip, 0, PingCallback);
if(socketPing == NULL)
return;
socketPing->userPtr = socketTelnet;
buf[0] = 'A';
IPWrite(socketPing, (uint8*)buf, 1);
1128,6 → 1138,8
OS_FILE *file;
(void)argv;
file = fopen("myfile.txt", "w");
if(file == NULL)
return;
fwrite("Hello World!", 1, 12, file);
fclose(file);
IPPrintf(socket, "Created myfile.txt");
1233,6 → 1245,7
 
#ifndef EXCLUDE_DLL
#ifndef WIN32
#undef DLL_SETUP
#define DLL_SETUP
#include "dll.h"
#else
1311,8 → 1324,9
FILE *file;
int bytes, i, run=0;
uint8 code[256];
char *argv2[12];
DllFunc funcPtr;
 
if(strcmp(argv[0], "run") == 0)
{
run = 1;
1331,15 → 1345,16
{
funcPtr = (DllFunc)ConsoleLoadElf(file, code);
fclose(file);
argv[-1] = (char*)DllFuncList; //DllF = argv[-1]
argv[-2] = (char*)socket;
argv2[0] = (char*)DllFuncList; //DllF = argv[-1]
argv2[1] = (char*)socket;
for(i = 0; i < 10; ++i)
{
argv2[i + 2] = argv[i];
if(argv[i] == 0)
break;
}
#ifndef WIN32
funcPtr(i, argv);
funcPtr(i, argv2 + 2);
#endif
return;
}
/kernel/rtos_test.c
61,7 → 61,7
rc = strncmp(s1, "Hellx", 4);
assert(rc == 0);
ptr = strstr(s1, "orl");
assert(ptr[0] == 'o');
assert(ptr && ptr[0] == 'o');
rc = strlen(s1);
assert(rc == 13);
memcpy(s2, s1, rc+1);
98,6 → 98,7
 
printf("TestHeap\n");
memset(ptrs, 0, sizeof(ptrs));
memset(size, 0, sizeof(size));
for(i = 0; i < 1000; ++i)
{
j = rand() & 255;
164,6 → 165,8
{
priority = 50 + i;
thread = OS_ThreadCreate("MyThread", MyThreadMain, (uint32*)i, priority, 0);
if(thread == NULL)
return;
OS_ThreadInfoSet(thread, 0, (void*)(0xabcd + i));
//printf("Created thread 0x%x\n", thread);
}
263,6 → 266,8
TestInfo_t info;
printf("TestMutex\n");
info.MyMutex = OS_MutexCreate("MyMutex");
if(info.MyMutex == NULL)
return;
OS_MutexPend(info.MyMutex);
OS_MutexPend(info.MyMutex);
OS_MutexPend(info.MyMutex);
297,6 → 302,8
 
printf("TestMQueue\n");
mqueue = OS_MQueueCreate("MyMQueue", 10, 16);
if(mqueue == NULL)
return;
strcpy(data, "Test0");
for(i = 0; i < 16; ++i)
{
342,7 → 349,7
static void TestTimer(void)
{
int i;
TestInfo_t info;
volatile TestInfo_t info;
 
printf("TestTimer\n");
info.TimerDone = 0;
350,7 → 357,7
{
info.MyQueue[i] = OS_MQueueCreate("MyQueue", 10, 16);
info.MyTimer[i] = OS_TimerCreate("MyTimer", info.MyQueue[i], i);
info.MyThread[i] = OS_ThreadCreate("TimerTest", TestTimerThread, &info, 50, 0);
info.MyThread[i] = OS_ThreadCreate("TimerTest", TestTimerThread, (void*)&info, 50, 0);
OS_ThreadInfoSet(info.MyThread[i], 0, (void*)i);
OS_TimerStart(info.MyTimer[i], 10+i*2, 220+i);
}
/kernel/rtos.c
988,13 → 988,18
uint32 message[4];
int rc;
 
OS_SemaphorePend(SemaphoreLock, OS_WAIT_FOREVER);
if(jobThread == NULL)
if(jobQueue == NULL)
{
jobQueue = OS_MQueueCreate("job", 100, 16);
jobThread = OS_ThreadCreate("job", JobThread, NULL, 150, 4000);
OS_SemaphorePend(SemaphoreLock, OS_WAIT_FOREVER);
if(jobQueue == NULL)
{
jobQueue = OS_MQueueCreate("job", 100, 16);
jobThread = OS_ThreadCreate("job", JobThread, NULL, 150, 4000);
}
OS_SemaphorePost(SemaphoreLock);
if(jobQueue == NULL)
return;
}
OS_SemaphorePost(SemaphoreLock);
 
message[0] = (uint32)funcPtr;
message[1] = (uint32)arg0;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.