-BUILD_NUM = 1389
+BUILD_NUM = 1398
break;
case TERM_MODE_FB:
- case TERM_MODE_OPENGL:
+ //case TERM_MODE_:
while(pos < Length)
{
while(term->InputRead == term->InputWrite) Threads_Yield();
free(Term->Text);
Term->Buffer = calloc( Term->Width*Term->Height, sizeof(Uint32) );
break;
- case TERM_MODE_OPENGL:
- return;
+ //case TERM_MODE_OPENGL:
+ // return;
}
Term->Mode = NewMode;
* \name Strings
* \{
*/
+extern int sprintf(char *__s, const char *__format, ...);
extern Uint strlen(const char *Str);
extern char *strcpy(char *__dest, const char *__src);
extern int strcmp(const char *__str1, const char *__str2);
extern void itoa(char *buf, Uint num, int base, int minLength, char pad);
extern int ReadUTF8(Uint8 *str, Uint32 *Val);
extern int WriteUTF8(Uint8 *str, Uint32 Val);
-extern int LookupString(char **Array, char *Needle);
+extern int ModUtil_SetIdent(char *Dest, char *Value);
+extern int ModUtil_LookupString(char **Array, char *Needle);
extern Uint8 ByteSum(void *Ptr, int Size);
/**
* \}
*/\r
TERM_MODE_FB,\r
\r
+ TERM_MODE_2DACCEL,\r
+ \r
/**\r
* \brief OpenGL 2D/3D\r
* Writes to the terminal file will send 3D commands\r
* Reads will return UTF-32 characters\r
* \note May or may not stay in the spec\r
*/\r
- TERM_MODE_OPENGL,\r
+ TERM_MODE_3D,\r
\r
/**\r
* \brief Number of terminal modes\r
NUM_TERM_MODES\r
};\r
\r
+enum eTplTerminal_2D_Commands\r
+{\r
+ TERM_2DCMD_NOP,\r
+ \r
+ /**\r
+ * (Uint16 X, Y, W, H, Uint32 Data[])\r
+ * \param X,Y Coordinates of Top-Left corner\r
+ * \param W,H Dimensions\r
+ * \param Data 32-bpp pixel data\r
+ */\r
+ TERM_2DCMD_PUSH,\r
+};\r
\r
#endif\r
buf[i] = 0;
}
+#define PUTCH(c) do{if(pos==__maxlen)break;if(__s){__s[pos++]=(c);}else{pos++;}}while(0)
+int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args)
+{
+ char c, pad = ' ';
+ int minSize = 0;
+ char tmpBuf[34]; // For Integers
+ char *p = NULL;
+ int isLongLong = 0;
+ Uint64 val;
+ size_t pos = 0;
+
+ while((c = *__format++) != 0)
+ {
+ // Non control character
+ if(c != '%') { PUTCH(c); continue; }
+
+ c = *__format++;
+
+ // Literal %
+ if(c == '%') { PUTCH('%'); continue; }
+
+ // Pointer - Done first for debugging
+ if(c == 'p') {
+ Uint ptr = va_arg(args, Uint);
+ PUTCH('*'); PUTCH('0'); PUTCH('x');
+ p = tmpBuf;
+ itoa(p, ptr, 16, BITS/4, '0');
+ goto printString;
+ }
+
+ // Get Argument
+ val = va_arg(args, Uint);
+
+ // - Padding
+ if(c == '0') {
+ pad = '0';
+ c = *__format++;
+ }
+ else
+ pad = ' ';
+
+ // - Minimum length
+ minSize = 1;
+ if('1' <= c && c <= '9')
+ {
+ minSize = 0;
+ while('0' <= c && c <= '9')
+ {
+ minSize *= 10;
+ minSize += c - '0';
+ c = *__format++;
+ }
+ }
+
+ // - Default, Long or LongLong?
+ isLongLong = 0;
+ if(c == 'l') // Long is actually the default on x86
+ {
+ c = *__format++;
+ if(c == 'l') {
+ #if BITS == 32
+ val |= (Uint64)va_arg(args, Uint) << 32;
+ #endif
+ c = *__format++;
+ isLongLong = 1;
+ }
+ }
+
+ // - Now get the format code
+ p = tmpBuf;
+ switch(c)
+ {
+ case 'd':
+ case 'i':
+ if( (isLongLong && val >> 63) || (!isLongLong && val >> 31) ) {
+ PUTCH('-');
+ val = -val;
+ }
+ itoa(p, val, 10, minSize, pad);
+ goto printString;
+ case 'u':
+ itoa(p, val, 10, minSize, pad);
+ goto printString;
+ case 'x':
+ itoa(p, val, 16, minSize, pad);
+ goto printString;
+ case 'o':
+ itoa(p, val, 8, minSize, pad);
+ goto printString;
+ case 'b':
+ itoa(p, val, 2, minSize, pad);
+ goto printString;
+
+ case 'B': //Boolean
+ if(val) p = "True";
+ else p = "False";
+ goto printString;
+
+ // String - Null Terminated Array
+ case 's':
+ p = (char*)(Uint)val;
+ printString:
+ if(!p) p = "(null)";
+ while(*p) PUTCH(*p++);
+ break;
+
+ case 'C': // Non-Null Terminated Character Array
+ p = (char*)(Uint)val;
+ if(!p) goto printString;
+ while(minSize--) PUTCH(*p++);
+ break;
+
+ // Single Character
+ case 'c':
+ default:
+ PUTCH( (Uint8)val );
+ break;
+ }
+ }
+
+ if(__s && pos != __maxlen)
+ __s[pos] = '\0';
+
+
+ return pos;
+}
+#undef PUTCH
+
+/**
+ */
+int sprintf(char *__s, const char *__format, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, __format);
+ ret = vsnprintf(__s, -1, __format, args);
+ va_end(args);
+
+ return ret;
+}
+
/**
* \fn int tolower(int c)
* \brief Converts a character to lower case
return __str1;
}
+/**
+ * \fn char *strcpy(const char *__str1, const char *__str2)
+ * \brief Copy a string to a new location
+ */
+char *strncpy(char *__str1, const char *__str2, size_t max)
+{
+ while(*__str2 && max-- >= 1)
+ *__str1++ = *__str2++;
+ if(max)
+ *__str1 = '\0'; // Terminate String
+ return __str1;
+}
+
/**
* \fn int strcmp(const char *str1, const char *str2)
* \brief Compare two strings return the difference between
* \brief Search a string array for \a Needle
* \note Helper function for eTplDrv_IOCtl::DRV_IOCTL_LOOKUP
*/
-int LookupString(char **Array, char *Needle)
+int ModUtil_LookupString(char **Array, char *Needle)
{
int i;
+ if( !CheckString(Needle) ) return -1;
for( i = 0; Array[i]; i++ )
{
if(strcmp(Array[i], Needle) == 0) return i;
return -1;
}
+int ModUtil_SetIdent(char *Dest, char *Value)
+{
+ if( !CheckMem(Dest, 32) ) return -1;
+ strncpy(Dest, Value, 32);
+ return 1;
+}
+
EXPORT(strlen);
EXPORT(strdup);
EXPORT(strcmp);
EXPORT(strncmp);
EXPORT(strcpy);
-//EXPORT(strncpy);
+EXPORT(strncpy);
EXPORT(timestamp);
EXPORT(ReadUTF8);
EXPORT(CheckMem);
EXPORT(CheckString);
-EXPORT(LookupString);
+EXPORT(ModUtil_LookupString);
+EXPORT(ModUtil_SetIdent);
case FAT12: sFatType = "FAT12"; break;\r
case FAT16: sFatType = "FAT16"; break;\r
case FAT32: sFatType = "FAT32"; break;\r
+ default: sFatType = "UNKNOWN"; break;\r
}\r
if(iSize <= 2*1024) {\r
sSize = "KiB";\r
for( i = 0; i < 4; i ++ )
{
if( mbr.Parts[i].SystemID == 0 ) continue;
- if(
- mbr.Parts[i].Boot == 0x0 || mbr.Parts[i].Boot == 0x80 // LBA 28
+ if( mbr.Parts[i].Boot == 0x0 || mbr.Parts[i].Boot == 0x80 // LBA 28
|| mbr.Parts[i].Boot == 0x1 || mbr.Parts[i].Boot == 0x81 // LBA 48
)
{
{\r
switch(ID)\r
{\r
- case DRV_IOCTL_TYPE:\r
- return DRV_TYPE_DISK;\r
+ case DRV_IOCTL_TYPE: return DRV_TYPE_DISK;\r
+ case DRV_IOCTL_IDENT: return ModUtil_SetIdent(Data, "FDD");\r
+ case DRV_IOCTL_VERSION: return FDD_VERSION;\r
+ case DRV_IOCTL_LOOKUP: return ModUtil_LookupString((char**)casIOCTLS, Data);\r
\r
- case DRV_IOCTL_IDENT:\r
- if(!CheckMem(Data, 4)) return -1;\r
- memcpy(Data, "FDD\0", 4);\r
- return 1;\r
- \r
- case DRV_IOCTL_VERSION:\r
- return FDD_VERSION;\r
- \r
- case DRV_IOCTL_LOOKUP:\r
- if(!CheckString(Data)) return -1;\r
- return LookupString((char**)casIOCTLS, Data);\r
- \r
- case DISK_IOCTL_GETBLOCKSIZE:\r
- return 512; \r
+ case DISK_IOCTL_GETBLOCKSIZE: return 512; \r
\r
default:\r
return 0;\r
*/
#define DEBUG 0
#define VERSION VER2(0,10)
+#define IDENT IPStack
#include "ipstack.h"
#include "link.h"
#include <modules.h>
tAdapter *IPStack_GetAdapter(char *Path);
// === GLOBALS ===
-MODULE_DEFINE(0, VERSION, IPStack, IPStack_Install, NULL, NULL);
+MODULE_DEFINE(0, VERSION, IDENT, IPStack_Install, NULL, NULL);
tDevFS_Driver gIP_DriverInfo = {
NULL, "ip",
{
return DRV_TYPE_MISC;
case DRV_IOCTL_IDENT:
- if( !CheckMem( Data, 4 ) ) LEAVE_RET('i', -1);
- memcpy(Data, "IP\0\0", 4);
+ tmp = ModUtil_SetIdent(Data, STR(IDENT));
LEAVE('i', 1);
return 1;
return VERSION;
case DRV_IOCTL_LOOKUP:
- if( !CheckString( Data ) ) LEAVE_RET('i', -1);
- LOG("Lookup '%s'", Data);
- tmp = LookupString( (char**)casIOCtls_Root, (char*)Data );
+ tmp = ModUtil_LookupString( (char**)casIOCtls_Root, (char*)Data );
LEAVE('i', tmp);
return tmp;
return DRV_TYPE_MISC;
case DRV_IOCTL_IDENT:
- if( !CheckMem( Data, 4 ) ) LEAVE_RET('i', -1);
- memcpy(Data, "IP\0\0", 4);
+ tmp = ModUtil_SetIdent(Data, STR(IDENT));
LEAVE('i', 1);
return 1;
return VERSION;
case DRV_IOCTL_LOOKUP:
- if( !CheckString( Data ) ) LEAVE_RET('i', -1);
- LOG("Lookup '%s'", Data);
- tmp = LookupString( (char**)casIOCtls_Iface, (char*)Data );
+ tmp = ModUtil_LookupString( (char**)casIOCtls_Iface, (char*)Data );
LEAVE('i', tmp);
return tmp;
_CPPFLAGS := $(CPPFLAGS)
--include ../../Makefile.cfg
+CFGFILES =
+CFGFILES += $(shell test -f ../../Makefile.cfg && echo ../../Makefile.cfg)
+CFGFILES += $(shell test -f ../Makefile.cfg && echo ../Makefile.cfg)
+CFGFILES += $(shell test -f Makefile.cfg && echo Makefile.cfg)
+-include $(CFGFILES)
-CPPFLAGS = -I../../Kernel/include -I../../Kernel/arch/$(ARCHDIR)/include -DARCH=$(ARCH) $(_CPPFLAGS)
+CPPFLAGS = -I$(ACESSDIR)/Kernel/include -I$(ACESSDIR)/Kernel/arch/$(ARCHDIR)/include -DARCH=$(ARCH) $(_CPPFLAGS)
CFLAGS = -Wall -Werror -fno-stack-protector $(CPPFLAGS)
OBJ := $(addsuffix .$(ARCH),$(OBJ))
$(BIN): $(OBJ)
@echo --- $(LD) -o $@
- @$(LD) -T ../link.ld -shared -nostdlib -o $@ $(OBJ)
+ @$(LD) -T $(ACESSDIR)/Modules/link.ld -shared -nostdlib -o $@ $(OBJ)
@$(OBJDUMP) -d $(BIN) > $(BIN).dsm
@echo --- $(LD) -o $(KOBJ)
@$(CC) -Wl,-r -nostdlib -o $(KOBJ) $(OBJ)
-%.o.$(ARCH): %.c Makefile ../Makefile.tpl ../../Makefile.cfg
+%.o.$(ARCH): %.c Makefile ../Makefile.tpl $(CFGFILES)
@echo --- $(CC) -o $@
@$(CC) $(CFLAGS) -o $@ -c $<
@$(CC) -M $(CPPFLAGS) -MT $@ -o $*.d.$(ARCH) $<
return DRV_TYPE_NETWORK;
case DRV_IOCTL_IDENT:
- if(!CheckMem(Data, 4)) {
- LEAVE('i', -1);
- return -1;
- }
- memcpy(Data, "NE2K", 4);
- LEAVE('i', 1);
- return 1;
+ tmp = ModUtil_SetIdent(Data, "Ne2k");
+ LEAVE('i', tmp);
+ return tmp;
case DRV_IOCTL_VERSION:
LEAVE('x', VERSION);
return VERSION;
case DRV_IOCTL_LOOKUP:
- if( !CheckString(Data) ) {
- LEAVE('i', -1);
- return -1;
- }
- tmp = LookupString( (char**)casIOCtls, Data );
+ tmp = ModUtil_LookupString( (char**)casIOCtls, Data );
LEAVE('i', tmp);
return tmp;
}