summaryrefslogtreecommitdiffstats
path: root/sw-old/z80/libc/include
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-10-30 11:41:24 +0100
committerNao Pross <naopross@thearcway.org>2018-10-30 11:41:24 +0100
commit43be150dc6e84f6f6eeb071cd3cdb7fc21125d60 (patch)
tree541fd3d690c1bdfd7b68d684029a400b80f4aa06 /sw-old/z80/libc/include
parentAdd datasheets for ATmega328 and 74LS259 (diff)
downloadz80uPC-43be150dc6e84f6f6eeb071cd3cdb7fc21125d60.tar.gz
z80uPC-43be150dc6e84f6f6eeb071cd3cdb7fc21125d60.zip
Move sw to sw-old and hw to hw-altium, add kicad files
Diffstat (limited to 'sw-old/z80/libc/include')
-rw-r--r--sw-old/z80/libc/include/stdint.h13
-rw-r--r--sw-old/z80/libc/include/stdio.h11
-rw-r--r--sw-old/z80/libc/include/stdlib.h7
-rw-r--r--sw-old/z80/libc/include/string.h12
-rw-r--r--sw-old/z80/libc/include/sysio.h55
-rw-r--r--sw-old/z80/libc/include/types.h60
6 files changed, 158 insertions, 0 deletions
diff --git a/sw-old/z80/libc/include/stdint.h b/sw-old/z80/libc/include/stdint.h
new file mode 100644
index 0000000..5e8caf3
--- /dev/null
+++ b/sw-old/z80/libc/include/stdint.h
@@ -0,0 +1,13 @@
+#ifndef __STDINT_H__
+#define __STDINT_H__
+
+typedef unsigned int uint;
+
+typedef char int8_t;
+typedef unsigned char uint8_t;
+typedef int int16_t;
+typedef unsigned int uint16_t;
+typedef long int int32_t;
+typedef unsigned long int uint32_t;
+
+#endif // __STDINT_H__ \ No newline at end of file
diff --git a/sw-old/z80/libc/include/stdio.h b/sw-old/z80/libc/include/stdio.h
new file mode 100644
index 0000000..b31cdfd
--- /dev/null
+++ b/sw-old/z80/libc/include/stdio.h
@@ -0,0 +1,11 @@
+#ifndef __STDIO_H__
+#define __STDIO_H__
+
+#include "types.h"
+
+extern uint8_t *stdout, stderr;
+
+void putc(char ch, uint8_t *buffer);
+int printf(const char *fmt, ...);
+
+#endif
diff --git a/sw-old/z80/libc/include/stdlib.h b/sw-old/z80/libc/include/stdlib.h
new file mode 100644
index 0000000..c69f573
--- /dev/null
+++ b/sw-old/z80/libc/include/stdlib.h
@@ -0,0 +1,7 @@
+#ifndef __STDLIB_H__
+#define __STDLIB_H__
+
+#include "stdint.h"
+
+
+#endif // __STDLIB_H__ \ No newline at end of file
diff --git a/sw-old/z80/libc/include/string.h b/sw-old/z80/libc/include/string.h
new file mode 100644
index 0000000..9c002e3
--- /dev/null
+++ b/sw-old/z80/libc/include/string.h
@@ -0,0 +1,12 @@
+#ifndef __STRING_H__
+#define __STRING_H__
+
+#include "types.h"
+
+void * memset(void *dest, const int8_t src, size_t n);
+
+void *memcpy(void *dest, const void *src, size_t n);
+
+int8_t memcmp(const void *s1, const void *s2, size_t n);
+
+#endif
diff --git a/sw-old/z80/libc/include/sysio.h b/sw-old/z80/libc/include/sysio.h
new file mode 100644
index 0000000..5d1f5ae
--- /dev/null
+++ b/sw-old/z80/libc/include/sysio.h
@@ -0,0 +1,55 @@
+#ifndef __SYSIO_H__
+#define __SYSIO_H__
+
+#include "types.h"
+
+/*
+* Memory management
+*/
+
+void * malloc(uint16_t size);
+uint16_t malloc_size(void * address);
+void free(void * address);
+
+/*
+* File management
+*/
+
+#define F_WRITE "w"
+#define F_READ "r"
+#define F_BIN_WRITE "wb"
+#define F_BIN_READ "rb"
+
+#define F_READ_CODE 0x0
+#define F_WRITE_CODE 0x1
+#define F_BIN_READ_CODE 0x2
+#define F_BIN_WRITE_CODE 0x3
+
+#define F_PERM_READ 0x0
+#define F_PERM_WRITE 0x1
+#define F_PERM_RW 0x2
+
+struct file {
+
+ const char * path;
+ unsigned int mode:4;
+ unsigned int permission:4;
+};
+
+#define FILE struct file
+
+FILE * fopen(const char * path, const char * mode);
+uint8_t fclose(FILE * file);
+
+// TODO: other functions
+
+/*
+* Processes management
+*/
+
+#define PID uint16_t
+
+void exit(); // exit this program
+void interrupt(PID)
+
+#endif \ No newline at end of file
diff --git a/sw-old/z80/libc/include/types.h b/sw-old/z80/libc/include/types.h
new file mode 100644
index 0000000..a083bfe
--- /dev/null
+++ b/sw-old/z80/libc/include/types.h
@@ -0,0 +1,60 @@
+#ifndef __TYPES_H__
+#define __TYPES_H__
+
+/* only types from primitive types are defined in this file */
+
+typedef volatile unsigned char register_t;
+
+typedef unsigned int uint;
+
+typedef char int8_t;
+typedef unsigned char uint8_t;
+typedef int int16_t;
+typedef unsigned int uint16_t;
+typedef long int int32_t;
+typedef unsigned long int uint32_t;
+
+typedef uint16_t size_t;
+typedef int16_t ssize_t;
+
+typedef uint8_t pid_t;
+typedef uint16_t ino_t;
+
+typedef uint8_t dev_t;
+typedef uint32_t devsize_t;
+typedef uint8_t fd_t;
+typedef uint16_t blk_t;
+typedef uint8_t user_t;
+typedef struct {
+ uint8_t member[3];
+} uint24_t;
+
+typedef uint32_t fsize_t;
+
+typedef struct
+{
+ dev_t dev; // device id, global in the fs
+ ino_t inode; // inode id relative to the volume
+
+} inode_t;
+
+typedef struct time_s
+{
+ struct
+ {
+ uint minutes :6;
+ uint hour :5;
+
+ } time;
+
+ struct
+ {
+ uint day :5;
+ uint month :4;
+ uint year :12;
+
+ } date;
+
+} time_t;
+
+#endif