summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2015-10-10 10:27:17 +0200
committerOlivier Gayot <duskcoder@gmail.com>2015-10-10 10:28:24 +0200
commitc51fa1f0e9b7ce6691d140245d48e4c843782f68 (patch)
treebaac22750b99d73d5462cb173301b43d06227537 /src/main.c
parentae5f4001c351b24a7f4e1bee6d995e4cb3cced2f (diff)
kfs: move the source files to follow the arborescence asked
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..8e59664
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,43 @@
+#define NB_COLS 80
+#define NB_ROWS 25
+
+/* XXX doest not always handle memory overlaps */
+static void my_memmove(void *dest, const void *src, size_t n)
+{
+ for (size_t i = 0; i < n; ++i) {
+ dest[i] = src[i];
+ }
+}
+
+static void my_memset(void *dest, int c, size_t n)
+{
+ for (size_t i = 0; i < n; ++i) {
+ dest[i] = c;
+ }
+}
+
+int printk(const char *str)
+{
+ static char *offset = (char *) 0xb8000;
+ static char *addr = offset;
+ int count = 0;
+
+ for (int i = 0; str[i]; ++i) {
+ if ((long)addr >= 0xb8000 + NB_COLS * NB_ROWS) {
+ /* shift up */
+ addr -= NB_COLS;
+ my_memmove(offset, offset + NB_COLS, NB_COLS * (NB_ROWS - 1));
+ my_memset(offset + NB_COLS * (NB_ROWS - 1), ' ', NB_ROWS);
+ }
+
+ *addr++ = str[i]
+ ++count;
+
+ }
+
+ return count;
+}
+
+int main(void)
+{
+}