aboutsummaryrefslogtreecommitdiffstats
path: root/src/user
diff options
context:
space:
mode:
Diffstat (limited to 'src/user')
-rw-r--r--src/user/Makefile22
-rw-r--r--src/user/priv_gpio.h58
-rw-r--r--src/user/user.c58
3 files changed, 44 insertions, 94 deletions
diff --git a/src/user/Makefile b/src/user/Makefile
index d22fbf3..ce23a89 100644
--- a/src/user/Makefile
+++ b/src/user/Makefile
@@ -1,9 +1,29 @@
+##
+# @file Makefile
+# Script to build folder of source files
+#
+# Copyright (C) 2018 Clyne Sullivan
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+#
+
CFILES = $(wildcard *.c)
AFILES = $(wildcard *.s)
OFILES = $(patsubst %.c, %.o, $(CFILES)) \
$(patsubst %.s, %.asm.o, $(AFILES))
-CFLAGS += -I.. -I../arch/cmsis
+CFLAGS += -ffreestanding -nostdlib -I.. -I../arch/cmsis
all: $(OFILES)
diff --git a/src/user/priv_gpio.h b/src/user/priv_gpio.h
deleted file mode 100644
index 6b349fe..0000000
--- a/src/user/priv_gpio.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * @file priv_gpio.h
- * GPIO access for unpriviledged processes
- *
- * Copyright (C) 2018 Clyne Sullivan
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-#ifndef PRIV_GPIO_H_
-#define PRIV_GPIO_H_
-
-// For value flags
-#include <kernel/gpio.h>
-
-/**
- * Possible GPIO calls.
- */
-enum GPIO_CALLS {
- GPIO_MODE = 0, /**< Change GPIO mode */
- GPIO_TYPE, /**< Change GPIO type (PuPd/ODrain) */
- GPIO_PUPD, /**< Set/clear pullup/pulldown */
- GPIO_SPEED, /**< Set GPIO speed */
- GPIO_OUT, /**< Set GPIO output state */
-};
-
-/**
- * Provides unpriviledged GPIO access.
- * @param call The type of GPIO call to make
- * @param pin The pin to modify (0-15 = A, 16-31 = B, ...)
- * @param value The value to pass to the call
- */
-void gpio(uint32_t call, uint32_t pin, uint32_t value)
-{
- register uint32_t r0 asm("r0") = call;
- register uint32_t r1 asm("r1") = pin;
- register uint32_t r2 asm("r2") = value;
-
- asm("\
- mov r0, %0; \
- mov r1, %1; \
- mov r2, %2; \
- svc 1; \
- " :: "r" (r0), "r" (r1), "r" (r2));
-}
-
-#endif // PRIV_GPIO_H_
diff --git a/src/user/user.c b/src/user/user.c
index b5ef789..f695936 100644
--- a/src/user/user.c
+++ b/src/user/user.c
@@ -1,41 +1,29 @@
-#include "priv_gpio.h"
+/**
+ * @file user.c
+ * Userspace entry
+ *
+ * Copyright (C) 2018 Clyne Sullivan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
-#include <kernel/clock.h>
-#include <kernel/heap.h>
-#include <kernel/vfs.h>
-
-void user_delay(uint32_t ms)
-{
- register uint32_t r1 asm("r1") = ms;
-
- asm("\
- mov r0, 0; \
- mov r1, %0; \
- svc 2; \
- " :: "r" (r1));
-}
+#include <syscalls.h>
+#include <stdio.h>
void user_main(void)
{
- gpio(GPIO_MODE, 5, OUTPUT);
-
- int test = vfs_open("B:/hello", VFS_FILE_READ);
- char *buf = malloc(20);
- int count = vfs_read(test, 20, (uint8_t *)buf);
- buf[count] = '\0';
- vfs_close(test);
-
-// if (fork() == 0) {
-// while (1) {
-// gpio(GPIO_OUT, 5, 1);
-// user_delay(2000);
-// }
-// } else {
-// while (1) {
-// user_delay(1000);
-// gpio(GPIO_OUT, 5, 0);
-// user_delay(1000);
-// }
-// }
+ //gpio(GPIO_MODE, 5, OUTPUT);
+ execve("B:/init", 0, 0);
}