#include <debug.h>
#include <arch.h>
#include <process.h>
+#include <sys/socket.h>
void cpu_debug(void);
int arch_init(void*);
void sched_tick(void);
+/*
+int socket(int, int, int);
+int close(int);
+*/
+
+int cxsend(pid_t, struct cxmsg*);
+int cxrecv(pid_t, struct cxmsg*);
void _print_mptbl(void *tbl)
{
return;
}
+static void _srv(void)
+{
+ while(1) {
+ struct cxmsg msg;
+
+ cxrecv(PID_ANY, &msg);
+
+ dbg_printf("MSG: [%u -> %u] %u\n", msg.cm_src, msg.cm_dst, msg.cm_type);
+ }
+
+ return;
+}
+
static void _idle(void)
{
+#if 0
+ int fd0;
+ int fd1;
+
+ fd0 = socket(PF_INET, SOCK_DGRAM, 0);
+
+ dbg_printf("socket(PF_INET, SOCK_DGRAM, 0) = 0x%08x\n", fd0);
+
+ fd1 = socket(PF_UNIX, SOCK_STREAM, 0);
+
+ dbg_printf("socket(PF_UNIX, SOCK_STREAM, 0) = 0x%08x\n", fd1);
+#endif
+
while(1) {
+/* int fd;
+
+ fd = socket(PF_INET, SOCK_DGRAM, 0);
+ dbg_printf("socket(PF_INET, SOCK_DGRAM, 0) = 0x%08x\n", fd);
+*/
+ cpu_set_pstate(1);
asm volatile("hlt");
}
return;
}
+static void _busy(void)
+{
+/* int fd, fe;
+
+ fd = socket(PF_INET, SOCK_DGRAM, 0);
+ fe = socket(PF_INET, SOCK_STREAM, 0);
+*/
+#if 0
+ if(fd >= 0) {
+ close(fd);
+ }
+
+ if(fe >= 0) {
+ close(fe);
+ }
+#endif
+
+#if 0
+ int sock;
+
+ sock = socket(PF_INET, SOCK_SEQPACKET, 0);
+
+ if(sock < 0) {
+ // dbg_printf("errno = %u\n", -sock);
+ }
+
+ sock = close(sock);
+
+ if(sock < 0) {
+ // dbg_printf("errno = %u\n", -sock);
+ }
+#endif
+
+ struct cxmsg msg;
+
+ cxsend(101, &msg);
+
+ for(;;);
+
+ return;
+}
+
int corax(void *mb_info, u32_t magic)
{
dbg_printf("Corax 0.1 - As the Crow flies\n");
dbg_printf("(C) 2019 Matthias Kruk <matt@corax.cc>\n");
dbg_printf("Compiled on %s at %s\n", __DATE__, __TIME__);
- u32_t p;
/*
void *ptr;
}
}
*/
-#if 0
- void *ptr;
-
- ptr = kmalloc(1024 * 1024);
-
- dbg_printf("Allocated 1024KB @ %p\n", ptr);
-
- kfree(ptr);
-#endif
-
- dbg_printf("Switching pstate\n");
-
- p = cpu_set_pstate(1);
- dbg_printf("Entered P-state %u. (0x%x)\n", p & 0xffff, p);
- dbg_printf("Initialisation complete. Nothing to do.\n");
process_t *proc;
process_t *proc2;
+ process_t *proc3;
u32_t err;
+ /* enqueue a second process */
err = process_create(&proc, 0, (void*)_idle);
if(err < 0) {
dbg_printf("process_create() = 0x%x\n", err);
}
- /* enqueue a second process */
- err = process_create(&proc2, 0, (void*)_idle);
+ err = process_create(&proc2, 0, (void*)_srv);
+
+ if(err < 0) {
+ dbg_printf("process_create() = 0x%x\n", err);
+ }
+
+ err = process_create(&proc3, 3, (void*)_busy);
if(err < 0) {
dbg_printf("process_create() = 0x%x\n", err);