All - Changes for AcessNative on windows
[tpg/acess2.git] / AcessNative / acesskernel_src / helpers.c
1 /*
2  * Acess2 Native Kernel
3  * - Acess kernel emulation on another OS using SDL and UDP
4  *
5  * Kernel Main
6  */
7 #include <arch.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <stdarg.h>
11 #include <sys/time.h>
12 #include <string.h>
13
14 #if 0
15 void LogF(const char *Fmt, ...)
16 {
17         va_list args;
18         va_start(args, Fmt);
19         vprintf(Fmt, args);
20         va_end(args);
21 }
22
23 void Log(const char *Fmt, ...)
24 {
25         va_list args;
26         printf("Log: ");
27         va_start(args, Fmt);
28         vprintf(Fmt, args);
29         va_end(args);
30         printf("\n");
31 }
32
33 void Warning(const char *Fmt, ...)
34 {
35         va_list args;
36         printf("Warning: ");
37         va_start(args, Fmt);
38         vprintf(Fmt, args);
39         va_end(args);
40         printf("\n");
41 }
42
43 void Panic(const char *Format, ...)
44 {
45         va_list args;
46         printf("Panic: ");
47         va_start(args, Format);
48         vprintf(Format, args);
49         va_end(args);
50         printf("\n");
51         exit(-1);
52 }
53
54 void Debug_SetKTerminal(const char *Path)
55 {
56         // Ignored, kernel debug goes to stdout instead of a virtual terminal
57 }
58 #endif
59
60 void KernelPanic_SetMode(void)
61 {
62         // NOP - No need
63 }
64 void KernelPanic_PutChar(char ch)
65 {
66         fprintf(stderr, "%c", ch);
67 }
68 void Debug_PutCharDebug(char ch)
69 {
70         printf("%c", ch);
71         if( ch == '\n' )
72                 fflush(stdout);
73 }
74 void Debug_PutStringDebug(const char *String)
75 {
76         printf("%s", String);
77         if( strchr(String, '\n') )
78                 fflush(stdout);
79 }
80
81 void *Heap_Allocate(const char *File, int Line, int ByteCount)
82 {
83         return malloc(ByteCount);
84 }
85
86 void *Heap_AllocateZero(const char *File, int Line, int ByteCount)
87 {
88         return calloc(ByteCount, 1);
89 }
90
91 void *Heap_Reallocate(const char *File, int Line, void *Ptr, int Bytes)
92 {
93         return realloc(Ptr, Bytes);
94 }
95
96 void Heap_Deallocate(void *Ptr)
97 {
98         free(Ptr);
99 }
100
101 char *Heap_StringDup(const char *File, int Line, const char *Str)
102 {
103         return strdup(Str);
104 }
105
106 void Heap_Dump(void)
107 {
108 }
109
110 tPAddr MM_GetPhysAddr(tVAddr VAddr)
111 {
112         return VAddr;   // HACK!
113 }
114
115 int MM_IsValidBuffer(tVAddr Base, int Size)
116 {
117         return 1;
118 }
119
120 Uint MM_GetFlags(tVAddr VAddr)
121 {
122         return 0;
123 }
124
125 int Modules_InitialiseBuiltin(const char *Name)
126 {
127         return 0;       // Ignored
128 }
129
130 Sint64 now(void)
131 {
132         struct timeval tv;
133         struct timezone tz;
134         gettimeofday(&tv, &tz);
135         return tv.tv_sec * 1000 + tv.tv_usec/1000;
136 }
137
138 void IPStack_SendDebugText(const char *str)
139 {
140         // nop
141 }
142
143 int strpos(const char *str, char ch)
144 {
145         const char *retptr = strchr(str, ch);
146         int rv = retptr ? retptr - str : -1;
147         fprintf(stderr, "strpos: str = %p'%s', retptr = %p, rv = %i\n", str, str, retptr, rv);
148         return rv;
149 }
150
151 int CheckString(const char *string)
152 {
153         if( (intptr_t)string < 0x1000 )
154                 return 0;
155         strlen(string);
156         return 1;
157 }
158
159 int CheckMem(const void *buf, size_t len)
160 {
161         if( (intptr_t)buf < 0x1000 )
162                 return 0;
163         return 1;
164 }
165

UCC git Repository :: git.ucc.asn.au