diff --git a/.cproject b/.cproject
index 755f1f1..0c17e32 100644
--- a/.cproject
+++ b/.cproject
@@ -45,7 +45,7 @@
-
+
diff --git a/.settings/org.eclipse.mylyn.tasks.ui.prefs b/.settings/org.eclipse.mylyn.tasks.ui.prefs
new file mode 100644
index 0000000..504c2a5
--- /dev/null
+++ b/.settings/org.eclipse.mylyn.tasks.ui.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+project.repository.kind=local
+project.repository.url=local
diff --git a/.settings/org.eclipse.wst.sse.core.prefs b/.settings/org.eclipse.wst.sse.core.prefs
new file mode 100644
index 0000000..eee1873
--- /dev/null
+++ b/.settings/org.eclipse.wst.sse.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+task-tags/enabled=true
+task-tags/taskPriorities=1,2,1,2
+task-tags/taskTags=TODO,FIXME,XXX,MrOlsen
+task-tags/use-project-settings=true
diff --git a/sys/armv6/syscall.c b/sys/armv6/syscall.c
index e20bb17..36a81d8 100644
--- a/sys/armv6/syscall.c
+++ b/sys/armv6/syscall.c
@@ -38,7 +38,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/sys/boot/arm/uboot/conf.c b/sys/boot/arm/uboot/conf.c
index 26cbeb1..93890ad 100644
--- a/sys/boot/arm/uboot/conf.c
+++ b/sys/boot/arm/uboot/conf.c
@@ -25,9 +25,9 @@
*
*/
+#ifdef _IGNORE
#include
-#ifdef _IGNORE
#include
#include "bootstrap.h"
diff --git a/sys/fs/vfs/inode.c b/sys/fs/vfs/inode.c
index 536a946..30816cc 100644
--- a/sys/fs/vfs/inode.c
+++ b/sys/fs/vfs/inode.c
@@ -30,9 +30,9 @@
#include
#include
-static struct inode *first_inode = NULL;
+//static struct inode *first_inode = NULL;
static struct wait_queue *inode_wait = NULL;
-static int nr_inodes = 0;
+//static int nr_inodes = 0;
static int nr_free_inodes = 0;
static void write_inode(struct inode * inode);
diff --git a/sys/i386/trap.c b/sys/i386/trap.c
index 8f09ccf..1a67afb 100644
--- a/sys/i386/trap.c
+++ b/sys/i386/trap.c
@@ -37,8 +37,6 @@
void die_if_kernel(char *str, struct trapframe *regs, long err);
-static void trap_end_task(char *string, struct trapframe *regs, long error_code);
-
#define TRAP_CODE(trap_nr, signr, str, trap_name, tsk) void do_##trap_name(struct trapframe *regs, long error_code) { \
die_if_kernel(str, regs, error_code); \
}
diff --git a/sys/include/net/arch/sys_arch.h b/sys/include/net/arch/sys_arch.h
index 439894a..c94add4 100644
--- a/sys/include/net/arch/sys_arch.h
+++ b/sys/include/net/arch/sys_arch.h
@@ -12,14 +12,6 @@
struct sys_timeout *next;
};
-struct sys_sem {
- uint32_t signaled;
- ubthread_cond_t cond;
- ubthread_mutex_t mutex;
-};
-
-typedef struct sys_sem sys_sem_t;
-
struct sys_mutex {
ubthread_mutex_t mutex;
};
diff --git a/sys/include/sys/sysproto.h b/sys/include/sys/sysproto.h
index 3564637..8fde3c7 100644
--- a/sys/include/sys/sysproto.h
+++ b/sys/include/sys/sysproto.h
@@ -736,4 +736,5 @@
int sys_socket(struct thread *td, struct sys_socket_args *);
int sys_setsockopt(struct thread *td, struct sys_setsockopt_args *);
int sys_select(struct thread *td, struct sys_select_args *);
+
#endif
diff --git a/sys/include/ubixos/errno.h b/sys/include/ubixos/errno.h
index 516f4c0..93bce50 100644
--- a/sys/include/ubixos/errno.h
+++ b/sys/include/ubixos/errno.h
@@ -1,39 +1,31 @@
-/**
- * @file
- * Posix Errno defines
- */
-
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+/*-
+ * Copyright (c) 2002-2018 The UbixOS Project.
* All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
+ * This was developed by Christopher W. Olsen for the UbixOS Project.
*
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * Redistribution and use in source and binary forms, with or without modification, are permitted
+ * provided that the following conditions are met:
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
+ * 1) Redistributions of source code must retain the above copyright notice, this list of
+ * conditions, the following disclaimer and the list of authors.
+ * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
+ * conditions, the following disclaimer and the list of authors in the documentation and/or
+ * other materials provided with the distribution.
+ * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
+ * endorse or promote products derived from this software without specific prior written
+ * permission.
*
- * This file is part of the lwIP TCP/IP stack.
- *
- * Author: Adam Dunkels
- *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#ifndef _UBIXOS_ERRNO_H
#define _UBIXOS_ERRNO_H
@@ -177,4 +169,4 @@
}
#endif
-#endif /* LWIP_HDR_ERRNO_H */
+#endif /* _UBIXOS_ERRNO*/
diff --git a/sys/include/ubixos/sem.h b/sys/include/ubixos/sem.h
index bb5f6eb..44694b5 100644
--- a/sys/include/ubixos/sem.h
+++ b/sys/include/ubixos/sem.h
@@ -30,6 +30,15 @@
#define _UBIXOS_SEM_H
#include
+#include
+
+struct sys_sem {
+ uint32_t signaled;
+ ubthread_cond_t cond;
+ ubthread_mutex_t mutex;
+};
+
+typedef struct sys_sem sys_sem_t;
typedef uint32_t semID_t;
struct timespec;
@@ -39,10 +48,10 @@
int sem_wait(semID_t id);
int sem_trywait(semID_t id);
int sem_timedwait(semID_t id, const struct timespec);
-int sem_init(semID_t *id, unsigned int value);
+err_t sem_init(sys_sem_t **, uint8_t);
int sem_open(semID_t *id, const char *name, int oflag, mode_t mode, unsigned int value);
int sem_unlink(const char *name);
int sem_getvalue(semID_t id, int *val);
-int sem_destroy(semID_t id);
+err_t sem_destroy(sys_sem_t **);
#endif /* END _UBIXOS_SEM_H */
diff --git a/sys/init/main.c b/sys/init/main.c
index 7e7c232..d78e605 100644
--- a/sys/init/main.c
+++ b/sys/init/main.c
@@ -72,6 +72,8 @@
Notes:
+ MrOlsen: test
+
*****************************************************************************************/
ubixDescriptorTable(ubixGDT, 11) {
{ .dummy = 0},
diff --git a/sys/init/static.c b/sys/init/static.c
index ed697d8..e289999 100644
--- a/sys/init/static.c
+++ b/sys/init/static.c
@@ -26,18 +26,12 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include
-
-/**
- * \brief Sets up the ctors
- */
-
+// XXX Set up the ctors
int static_constructors(void) {
extern void (*__ctor_list)();
void (**l_ctor)() = &__ctor_list;
int l_ctorCount = *(int *) l_ctor;
-// kprintf("Calling static constructors\n");
l_ctor++;
while (l_ctorCount) {
(*l_ctor)();
@@ -46,7 +40,3 @@
}
return (0x0);
}
-
-/***
- END
- ***/
diff --git a/sys/kernel/sem.c b/sys/kernel/sem.c
index 937ddbe..94d0b1c 100644
--- a/sys/kernel/sem.c
+++ b/sys/kernel/sem.c
@@ -27,6 +27,8 @@
*/
#include
+#include
+#include
#include
int sem_close(semID_t id) {
@@ -49,8 +51,22 @@
return(0);
}
-int sem_init(semID_t *id, unsigned int value) {
- return(0);
+err_t sys_init(sys_sem_t **sem, uint8_t count) {
+ sys_sem_t *newSem = 0x0;
+
+ if (*sem != 0) {
+ kpanic("UH OH!");
+ }
+
+ newSem = kmalloc(sizeof(struct sys_sem));
+ newSem->signaled = count;
+
+ ubthread_cond_init(&(newSem->cond), NULL);
+ ubthread_mutex_init(&(newSem->mutex), NULL);
+
+ *sem = newSem;
+
+ return (ERR_OK);
}
int sem_open(semID_t *id, const char *name, int oflag, mode_t mode, unsigned int value) {
@@ -65,7 +81,18 @@
return(0);
}
-int sem_destroy(semID_t id) {
- return(0);
+err_t sem_destroy(sys_sem_t **sem) {
+ if (*sem == NULL)
+ return (EINVAL);
+
+ sys_sem_t *d_sem = *sem;
+
+ ubthread_cond_destroy(&(d_sem->cond));
+ ubthread_mutex_destroy(&(d_sem->mutex));
+
+ kfree(sem);
+ *sem = 0x0;
+
+ return (ERR_OK);
}
diff --git a/sys/kernel/syscalls_posix.c b/sys/kernel/syscalls_posix.c
index 934a7fb..f0cf564 100644
--- a/sys/kernel/syscalls_posix.c
+++ b/sys/kernel/syscalls_posix.c
@@ -113,7 +113,7 @@
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 79 - Invalid */
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 80 - Invalid */
{ ARG_COUNT(sys_getpgrp_args), "getpgrp", sys_getpgrp, SYSCALL_VALID }, // 81 - getpgrp
- { ARG_COUNT(sys_setpgid_args), "setpgid", sys_setpgid, SYSCALL_VALID }, // 82 - setpgid
+ { ARG_COUNT(sys_setpgid_args), "setpgid", sys_setpgid, SYSCALL_VALID }, // 82 - setpgid
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 83 - Invalid */
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 84 - Invalid */
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 85 - Invalid */
@@ -196,7 +196,7 @@
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 162 - Invalid */
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 163 - Invalid */
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 164 - Invalid */
- { ARG_COUNT(sys_sysarch_args), "sysarch", sys_sysarch, SYSCALL_VALID }, /* 165 - sysarch */
+ { ARG_COUNT(sys_sysarch_args), "sysarch", sys_sysarch, SYSCALL_VALID }, // 165 - sysarch
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 166 - Invalid */
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 167 - Invalid */
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 168 - Invalid */
@@ -212,7 +212,7 @@
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 178 - Invalid */
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 179 - Invalid */
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 180 - Invalid */
- { ARG_COUNT(sys_setGID_args), "Set GID", (sys_call_t *) sys_setGID, SYSCALL_VALID }, /* 181 - Invalid */
+ { ARG_COUNT(sys_setGID_args), "Set GID", (sys_call_t *) sys_setGID, SYSCALL_VALID }, // 181 - getgid
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 182 - Invalid */
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 183 - Invalid */
{ 0, "No Call", sys_invalid, SYSCALL_VALID }, /* 184 - Invalid */
diff --git a/sys/kernel/time.c b/sys/kernel/time.c
index c5d470e..9631760 100644
--- a/sys/kernel/time.c
+++ b/sys/kernel/time.c
@@ -84,32 +84,36 @@
return (0x0);
}
-uInt32 timeMake(struct timeStruct *time) {
- uInt32 res;
+uint32_t timeMake(struct timeStruct *time) {
+ uint32_t res;
int year;
year = (time->year + 100) - 70;
+
/* magic offsets (y+1) needed to get leapyears right.*/
res = YEAR * year + DAY * ((year + 1) / 4);
+
res += month[time->mon];
+
/* and (y+2) here. If it wasn't a leap-year, we have to adjust */
if (time->mon > 1 && ((year + 2) % 4))
res -= DAY;
+
res += DAY * (time->day - 1);
res += HOUR * time->hour;
res += MINUTE * time->min;
res += time->sec;
+
return (res);
}
int gettimeofday(struct timeval *tp, struct timezone *tzp) {
- //tp->tv_sec = systemVitals->timeStart + systemVitals->sysUptime;
- tp->tv_sec = 0x0; //systemVitals->sysUptime;
+ tp->tv_sec = systemVitals->timeStart + systemVitals->sysUptime;
+ //tp->tv_sec = 0x0; //systemVitals->sysUptime;
tp->tv_usec = 0x0;
+
+ tzp->tz_minuteswest = (-5 * 60);
+ tzp->tz_dsttime = 0x0;
+
return (0x0);
}
-
-/***
- END
- ***/
-
diff --git a/sys/lib/kmalloc.c b/sys/lib/kmalloc.c
index 4fd419e..cf3bc34 100644
--- a/sys/lib/kmalloc.c
+++ b/sys/lib/kmalloc.c
@@ -37,11 +37,11 @@
/*
Set up three descriptor tables:
-
- kernDesc - The inuse descriptor table
+
+ kernDesc - The inuse descriptor table
freeKernDesc - The free descriptor table (descriptors with memory backing just not in use)
emptyKernDesc - The empty descriptor table (descriptors with out a memory backing)
-
+
*/
static struct memDescriptor *usedKernDesc = 0x0;
static struct memDescriptor *freeKernDesc = 0x0;
@@ -179,6 +179,7 @@
03/05/03 - We Have A Problem It Seems The First Block Is Limit 0x0
************************************************************************/
+#ifdef _IGNORE
static void mergeMemBlocks() {
struct memDescriptor *tmpDesc1 = 0x0;
struct memDescriptor *tmpDesc2 = 0x0;
@@ -228,6 +229,7 @@
}
return;
}
+#endif
/************************************************************************
diff --git a/sys/lib/kprintf.c b/sys/lib/kprintf.c
index 9675f15..906b880 100644
--- a/sys/lib/kprintf.c
+++ b/sys/lib/kprintf.c
@@ -66,7 +66,7 @@
*/
if (vq == 0) {
/* divide by zero. */
- static volatile const unsigned int zero = 0;
+ static const volatile unsigned int zero = 0;
tmp.ul[H] = tmp.ul[L] = 1 / zero;
if (arq)
@@ -309,7 +309,7 @@
* ("%*D", len, ptr, " " -> XX XX XX XX ...
*/
-int kvprintf(char const *fmt, void (*func)(int, void*), void *arg, int radix, va_list ap) {
+int kvprintf(const char *fmt, void (*func)(int, void*), void *arg, int radix, va_list ap) {
#define PCHAR(c) {int cc=(c); if (func) (*func)(cc,arg); else *d++ = cc; retval++; }
char nbuf[MAXNBUF];
char *d;
@@ -653,6 +653,7 @@
}
}
#undef PCHAR
+ return (0);
}
static char *ksprintn(char *nbuf, uintmax_t num, int base, int *lenp, int upper) {
diff --git a/sys/lib/strtok.c b/sys/lib/strtok.c
index 2b0c608..4836404 100644
--- a/sys/lib/strtok.c
+++ b/sys/lib/strtok.c
@@ -70,6 +70,7 @@
} while (sc != 0);
}
/* NOTREACHED */
+ return (NULL);
}
char *strtok(char *s, const char *delim) {
diff --git a/sys/lib/vsprintf.c b/sys/lib/vsprintf.c
index 7cd6daa..0c303e5 100644
--- a/sys/lib/vsprintf.c
+++ b/sys/lib/vsprintf.c
@@ -70,7 +70,7 @@
if (base < 2 || base > 36)
return 0;
c = (type & ZEROPAD) ? '0' : ' ';
- if (type & SIGN && num < 0) {
+ if ((type & SIGN) && num < 0) {
sign = '-';
num = -num;
}
diff --git a/sys/net/net/sys_arch.c b/sys/net/net/sys_arch.c
index 369adbf..6bec82a 100644
--- a/sys/net/net/sys_arch.c
+++ b/sys/net/net/sys_arch.c
@@ -14,6 +14,7 @@
#include
#include
+#include
/* Get Definitions For These */
#define ERR_NOT_READY 0
@@ -33,6 +34,7 @@
gettimeofday(&starttime, &tz);
}
+#ifdef _IGNORE
static struct sys_sem *sys_sem_new_internal(uint8_t count) {
struct sys_sem *sem;
@@ -44,9 +46,13 @@
}
return sem;
}
+#endif
/* Create a new semaphore */
err_t sys_sem_new(sys_sem_t **sem, uint8_t count) {
+ return (sem_init(sem, count));
+
+#ifdef __IGNORE
sys_sem_t *newSem = 0x0;
if (*sem != 0) {
@@ -62,14 +68,21 @@
*sem = newSem;
return (ERR_OK);
+#endif
}
/* Deallocate semaphore */
void sys_sem_free(struct sys_sem **sem) {
+ sem_destroy(sem);
+
+#ifdef _IGNORE
if ((sem != NULL) && (*sem != SYS_SEM_NULL)) {
sys_sem_free_internal(*sem);
*sem = 0x0;
}
+#endif
+
+
}
/* Signal semaphore */
@@ -89,12 +102,6 @@
ubthread_mutex_unlock(&(sem->mutex));
}
-static void sys_sem_free_internal(struct sys_sem *sem) {
- ubthread_cond_destroy(&(sem->cond));
- ubthread_mutex_destroy(&(sem->mutex));
- kfree(sem);
-}
-
uint32_t sys_arch_sem_wait(struct sys_sem **s, uint32_t timeout) {
uint32_t time_needed = 0;
struct sys_sem *sem;
diff --git a/sys/sys/device.c b/sys/sys/device.c
index 7ea9c68..414dc70 100644
--- a/sys/sys/device.c
+++ b/sys/sys/device.c
@@ -42,7 +42,7 @@
Description: This will add a device to the system
- Notes:
+ Notes:
05/19/2004 - Improving Upon the spec
@@ -76,7 +76,7 @@
Description: This will find a device based on major minor
- Notes:
+ Notes:
05/19/2004 - Improving Upon the spec
@@ -135,7 +135,3 @@
spinUnlock(&deviceSpinLock);
return 0x0;
}
-
-/***
- END
- ***/
diff --git a/sys/sys/dma.c b/sys/sys/dma.c
index d6b6615..50505fb 100644
--- a/sys/sys/dma.c
+++ b/sys/sys/dma.c
@@ -39,7 +39,7 @@
static uInt8 pagePort[8] = { 0x87, 0x83, 0x81, 0x82, 0x8F, 0x8B, 0x89, 0x8A };
static uInt8 countPort[8] = { 0x01, 0x03, 0x05, 0x07, 0xC2, 0xC6, 0xCA, 0xCE };
-void dmaXfer(uInt8 channel, uInt32 address, uInt length, uInt8 read) {
+void dmaXfer(uint8_t channel, uint32_t address, uInt length, uint8_t read) {
unsigned char page = 0, mode = 0;
unsigned int offset = 0;
if (read) {
@@ -67,7 +67,3 @@
outportByte(maskReg[dmaChannel], dmaChannel);
//asm("sti");
}
-
-/***
- END
- ***/
diff --git a/sys/sys/elf.c b/sys/sys/elf.c
index abd1941..b82327c 100644
--- a/sys/sys/elf.c
+++ b/sys/sys/elf.c
@@ -27,7 +27,3 @@
*/
#include
-
-/***
- END
- ***/
diff --git a/sys/sys/idt.c b/sys/sys/idt.c
index f0c7496..d22f038 100644
--- a/sys/sys/idt.c
+++ b/sys/sys/idt.c
@@ -41,7 +41,7 @@
#include
#include
-#define FP_TO_LINEAR(seg, off) ((void*) ((((uInt16) (seg)) << 4) + ((uInt16) (off))))
+#define FP_TO_LINEAR(seg, off) ((void*) ((((uint16_t) (seg)) << 4) + ((uint16_t) (off))))
static ubixDescriptorTable(ubixIDT, 256) {};
@@ -180,12 +180,6 @@
/* Null Intterupt Descriptor */
void intNull() {
kprintf("Invalid Interrupt[%i]\n", _current->id);
- /*
- kpanic("Invalid Interrupt[%i]\n",_current->id);
- while (1);
- endTask(_current->id);
- sched_yield();
- */
}
asm volatile(
@@ -266,9 +260,7 @@
);
void __int6(struct trapframe *frame) {
- die_if_kernel("invalid_op", frame, 6);
- //kprintf("tf_gs: 0x%X, tf_fs: 0x%X, tf_es: 0x%X, tf_ds: 0x%X\n", frame->tf_gs, frame->tf_fs, frame->tf_es, frame->tf_ds);
- //kpanic( "int6: Invalid opcode! [%i:0x%X:0x%X]\n", _current->id, _current->tss.eip, frame->tf_eip );
+ die_if_kernel("invalid_opcode", frame, 6);
endTask(_current->id);
sched_yield();
}
@@ -317,9 +309,9 @@
}
void _int13() {
- uInt8 *ip = 0x0;
- uInt16 *stack = 0x0, *ivt = 0x0;
- uInt32 *stack32 = 0x0;
+ uint8_t *ip = 0x0;
+ uint16_t *stack = 0x0, *ivt = 0x0;
+ uint32_t *stack32 = 0x0;
bool isOperand32 = FALSE, isAddress32 = FALSE;
struct tssStruct *gpfTSS = (struct tssStruct *) 0x4200;
@@ -505,7 +497,3 @@
" popl %eax \n"
" iret \n"
);
-
-/***
- END
- ***/
diff --git a/sys/sys/io.c b/sys/sys/io.c
index fbc3f51..8fb75b7 100644
--- a/sys/sys/io.c
+++ b/sys/sys/io.c
@@ -139,7 +139,3 @@
);
return (retVal);
}
-
-/***
- END
- ***/
diff --git a/sys/vmm/copyvirtualspace.c b/sys/vmm/copyvirtualspace.c
index 5b82c98..bee100a 100644
--- a/sys/vmm/copyvirtualspace.c
+++ b/sys/vmm/copyvirtualspace.c
@@ -36,7 +36,7 @@
/************************************************************************
- Function: void *vmmCopyVirtualSpace(pidType pid);
+ Function: void *vmm_copyVirtualSpace(pidType pid);
Description: Creates A Copy Of A Virtual Space And Set All NON Kernel
Space To COW For A Fork This Will Also Alter The Parents
@@ -115,11 +115,6 @@
/* Copy The Stack Byte For Byte (I Should Find A Faster Way) */
memcpy(newStackPage, parentStackPage, PAGE_SIZE);
- /*
- for (s = 0x0; s < PD_ENTRIES; s++) {
- newStackPage[s] = parentStackPage[s];
- }
- */
/* Insert New Stack Into Page Table */
newPageTable[i] = (vmm_getPhysicalAddr((uint32_t) newStackPage) | PAGE_DEFAULT | PAGE_STACK);
@@ -208,7 +203,6 @@
newPageDirectory[PD_INDEX(PD_BASE_ADDR)] = (uint32_t) (vmm_getPhysicalAddr((uint32_t) newPageTable) | PAGE_DEFAULT);
newPageTable[0] = (uint32_t) ((uint32_t) (newPageDirectoryAddress) | PAGE_DEFAULT);
- //MrOlsen (2017-12-15) - kprintf( "PD3: %i - 0x%X - 0x%X\n", PD_INDEX( PD_BASE_ADDR ), newPageDirectoryAddress, newPageTable[0] );
vmm_unmapPage((uint32_t) newPageTable, 1);
diff --git a/sys/vmm/createvirtualspace.c b/sys/vmm/createvirtualspace.c
index ca620a3..7f0dcdf 100644
--- a/sys/vmm/createvirtualspace.c
+++ b/sys/vmm/createvirtualspace.c
@@ -30,7 +30,7 @@
/************************************************************************
- Function: void *vmmCreateVirtualSpace(pid_t);
+ Function: void *vmm_createVirtualSpace(pid_t);
Description: Creates A Virtual Space For A New Task
Notes:
diff --git a/sys/vmm/freevirtualpage.c b/sys/vmm/freevirtualpage.c
index d42638b..2cf983f 100644
--- a/sys/vmm/freevirtualpage.c
+++ b/sys/vmm/freevirtualpage.c
@@ -29,5 +29,6 @@
#include
int vmm_freeVirtualPage(uint32_t addr) {
+ //TODO: Implement this
return (0);
}
diff --git a/sys/vmm/getfreepage.c b/sys/vmm/getfreepage.c
index b406cc4..c002bfb 100644
--- a/sys/vmm/getfreepage.c
+++ b/sys/vmm/getfreepage.c
@@ -54,14 +54,19 @@
/* Set Page Table Address */
pageTableSrc = (uInt32 *) (PT_BASE_ADDR + (0x1000 * x));
+
for (y = 0x0; y < 1024; y++) {
+
/* Loop Through The Page Table Find An UnAllocated Page */
if ((uInt32) pageTableSrc[y] == (uInt32) 0x0) {
+
/* Map A Physical Page To The Virtual Page */
if ((vmm_remapPage(vmm_findFreePage(pid), ((x * 0x400000) + (y * 0x1000)), KERNEL_PAGE_DEFAULT, pid)) == 0x0)
kpanic("vmmRemapPage: vmm_getFreePage\n");
+
/* Clear This Page So No Garbage Is There */
vmm_clearVirtualPage((uInt32) ((x * 0x400000) + (y * 0x1000)));
+
/* Return The Address Of The Newly Allocate Page */
spinUnlock(&vmmGFPlock);
return ((void *) ((x * 0x400000) + (y * 0x1000)));
@@ -71,10 +76,6 @@
/* If No Free Page Was Found Return NULL */
spinUnlock(&vmmGFPlock);
+
return (0x0);
}
-
-/***
- END
- ***/
-
diff --git a/sys/vmm/getphysicaladdr.c b/sys/vmm/getphysicaladdr.c
index 6e91501..eb9c5f4 100644
--- a/sys/vmm/getphysicaladdr.c
+++ b/sys/vmm/getphysicaladdr.c
@@ -29,16 +29,15 @@
#include
/*!
-
- Function: void *vmmGetPhysicalAddr();
+ Function: void *vmm_getPhysicalAddr();
Description: Returns The Physical Address Of The Virtual Page
Notes:
-
*/
-uint32_t vmm_getPhysicalAddr(uInt32 pageAddr) {
+/* returns the real address of page is page aligned */
+uint32_t vmm_getPhysicalAddr(uint32_t pageAddr) {
int pageDirectoryIndex = 0x0, pageTableIndex = 0x0;
- uInt32 *pageTable = 0x0;
+ uint32_t *pageTable = 0x0;
//Calculate The Page Directory Index
pageDirectoryIndex = (pageAddr >> 22);
@@ -47,11 +46,13 @@
pageTableIndex = ((pageAddr >> 12) & 0x3FF);
/* Set pageTable To The Virtual Address Of Table */
- pageTable = (uInt32 *) (PT_BASE_ADDR + (0x1000 * pageDirectoryIndex));
+ pageTable = (uint32_t *) (PT_BASE_ADDR + (0x1000 * pageDirectoryIndex));
+
/* Return The Physical Address Of The Page */
- return ((uInt32) (pageTable[pageTableIndex] & 0xFFFFF000));
+ return ((uint32_t) (pageTable[pageTableIndex] & 0xFFFFF000));
}
+/* Returns the real address not page aligned */
uint32_t vmm_getRealAddr(uint32_t addr) {
int pageDirectoryIndex = 0x0, pageTableIndex = 0x0;
uint32_t *pageTable = 0x0;
@@ -67,7 +68,3 @@
/* Return The Physical Address Of The Page */
return ((uint32_t) (pageTable[pageTableIndex] & 0xFFFFF000) + (addr & 0xFFF));
}
-
-/***
- END
- ***/
diff --git a/sys/vmm/pagefault.c b/sys/vmm/pagefault.c
index 072ddb8..6dba711 100644
--- a/sys/vmm/pagefault.c
+++ b/sys/vmm/pagefault.c
@@ -60,7 +60,7 @@
uint32_t eip = frame->tf_eip;
uint32_t memAddr = cr2;
-//MrOlsen 2017-12-15 -
+//MrOlsen 2017-12-15 -
kprintf("CR2: [0x%X], EIP: 0x%X, ERR: 0x%X\n", cr2, frame->tf_eip, frame->tf_err);
/* Try to aquire lock otherwise spin till we do */
@@ -142,86 +142,3 @@
kprintf("CR2-RET");
return;
}
-
-/***
- $Log: pagefault.c,v $
- Revision 1.6 2006/12/05 14:10:21 reddawg
- Workign Distro
-
- Revision 1.5 2006/12/01 05:12:35 reddawg
- We're almost there... :)
-
- Revision 1.4 2006/11/21 13:25:49 reddawg
- A handful of changes ;)
-
- Revision 1.3 2006/11/06 19:10:12 reddawg
- Lots Of Updates... Still having issues with brk();
-
- Revision 1.2 2006/10/31 20:44:19 reddawg
- Lots of changes
-
- Revision 1.1.1.1 2006/06/01 12:46:13 reddawg
- ubix2
-
- Revision 1.2 2005/10/12 00:13:38 reddawg
- Removed
-
- Revision 1.1.1.1 2005/09/26 17:24:52 reddawg
- no message
-
- Revision 1.14 2004/08/25 22:02:41 reddawg
- task switching - We now are using software switching to be consistant with the rest of the world because all of this open source freaks gave me a hard time about something I liked. There doesn't seem to be any gain in performance but it is working fine and flawlessly
-
- Revision 1.13 2004/08/24 05:24:37 reddawg
- TCA Is A BONER!!!!
-
- Revision 1.12 2004/08/14 11:23:03 reddawg
- Changes
-
- Revision 1.11 2004/07/28 15:05:43 reddawg
- Major:
- Pages now have strict security enforcement.
- Many null dereferences have been resolved.
- When apps loaded permissions set for pages rw and ro
-
- Revision 1.10 2004/07/28 00:22:56 reddawg
- bah
-
- Revision 1.9 2004/07/28 00:17:05 reddawg
- Major:
- Disconnected page 0x0 from the system... Unfortunately this broke many things
- all of which have been fixed. This was good because nothing deferences NULL
- any more.
-
- Things affected:
- malloc,kmalloc,getfreepage,getfreevirtualpage,pagefault,fork,exec,ld,ld.so,exec,file
-
- Revision 1.8 2004/07/27 07:09:38 reddawg
- Put in a test for 0x0
-
- Revision 1.7 2004/07/26 19:15:49 reddawg
- test code, fixes and the like
-
- Revision 1.6 2004/07/24 23:04:44 reddawg
- Changes... mark let me know if you fault at pid 185 when you type stress
-
- Revision 1.5 2004/07/24 20:00:51 reddawg
- Lots of changes to the vmm subsystem.... Page faults have been adjust to now be blocking on a per thread basis not system wide. This has resulted in no more deadlocks.. also the addition of per thread locking has removed segfaults as a result of COW in which two tasks fault the same COW page and try to modify it.
-
- Revision 1.4 2004/07/24 17:47:28 reddawg
- vmm_pageFault: deadlock resolved thanks to a propper solution suggested by geist
-
- Revision 1.3 2004/07/19 02:05:26 reddawg
- vmmPageFault: had a potential memory leak here for one page it was still using sysID on certain COW scenarios
-
- Revision 1.2 2004/06/10 22:23:56 reddawg
- Volatiles
-
- Revision 1.1.1.1 2004/04/15 12:06:52 reddawg
- UbixOS v1.0
-
- Revision 1.4 2004/04/13 16:36:34 reddawg
- Changed our copyright, it is all now under a BSD-Style license
-
- END
- ***/
diff --git a/sys/vmm/paging.c b/sys/vmm/paging.c
index 890eaea..e90005c 100644
--- a/sys/vmm/paging.c
+++ b/sys/vmm/paging.c
@@ -580,22 +580,29 @@
#endif
*/
- for (x = (addr / (1024 * 4096)); x < PD_INDEX(VMM_USER_END); x++) {
+ for (x = (addr / (PD_ENTRIES * PAGE_SIZE)); x < PD_INDEX(VMM_USER_END); x++) {
+
if ((pageDir[x] & PAGE_PRESENT) == PAGE_PRESENT) {
- pageTableSrc = (uint32_t *) (PT_BASE_ADDR + (0x1000 * x));
- for (y = 0; y < 1024; y++) {
+
+ pageTableSrc = (uint32_t *) (PT_BASE_ADDR + (PAGE_SIZE * x));
+
+ for (y = 0; y < PAGE_SIZE; y++) {
+
if ((pageTableSrc[y] & PAGE_PRESENT) == PAGE_PRESENT) {
+
if ((pageTableSrc[y] & PAGE_COW) == PAGE_COW) {
- //kprintf( "COW: 0x%X", (x * 0x400000) + (y * 0x1000) );
+
+ adjustCowCounter(((uint32_t) pageTableSrc[y] & 0xFFFFF000), -1);
pageTableSrc[y] = 0x0;
+
}
else if ((pageTableSrc[y] & PAGE_STACK) == PAGE_STACK) {
+ //TODO: We need to fix this so we can clean the stack!
//kprintf("Page Stack!: 0x%X", (x * 0x400000) + (y * 0x1000));
// pageTableSrc[y] = 0x0;
//MrOlsen (2016-01-18) NOTE: WHat should I Do Here? kprintf( "STACK: (%i:%i)", x, y );
}
else {
- //MrOlsen 2017-12-15 - kprintf( "Page Regular!: 0x%X", (x * 0x400000) + (y * 0x1000) );
pageTableSrc[y] = 0x0;
}
}
@@ -610,8 +617,3 @@
return (0x0);
}
-
-/***
- END
- ***/
-
diff --git a/sys/vmm/setpageattributes.c b/sys/vmm/setpageattributes.c
index 894e626..05fecd3 100644
--- a/sys/vmm/setpageattributes.c
+++ b/sys/vmm/setpageattributes.c
@@ -31,15 +31,15 @@
/************************************************************************
- Function: void vmmSetPageAttributes(uInt32 pageAddr,int attributes;
+ Function: void vmm_setPageAttributes(uInt32 pageAddr,int attributes;
Description: This Function Will Set The Page Attributes Such As
A Read Only Page, Stack Page, COW Page, ETC.
Notes:
************************************************************************/
-int vmm_setPageAttributes(uInt32 memAddr, uInt16 attributes) {
- uInt16 directoryIndex = 0x0, tableIndex = 0x0;
- uInt32 *pageTable = 0x0;
+int vmm_setPageAttributes(uint32_t memAddr, uint16_t attributes) {
+ uint16_t directoryIndex = 0x0, tableIndex = 0x0;
+ uint32_t *pageTable = 0x0;
/* Calculate The Page Directory Index */
directoryIndex = (memAddr >> 22);
@@ -48,7 +48,7 @@
tableIndex = ((memAddr >> 12) & 0x3FF);
/* Set Table Pointer */
- if ((pageTable = (uInt32 *) (PT_BASE_ADDR + (0x1000 * directoryIndex))) == 0x0)
+ if ((pageTable = (uint32_t *) (PT_BASE_ADDR + (0x1000 * directoryIndex))) == 0x0)
kpanic("Error: pageTable == NULL, File: %s, Line: %i\n", __FILE__, __LINE__);
/* Set Attribute If Page Is Mapped */
@@ -65,36 +65,3 @@
/* Return */
return (0x0);
}
-
-/***
- $Log: setpageattributes.c,v $
- Revision 1.1.1.1 2006/06/01 12:46:13 reddawg
- ubix2
-
- Revision 1.2 2005/10/12 00:13:38 reddawg
- Removed
-
- Revision 1.1.1.1 2005/09/26 17:24:53 reddawg
- no message
-
- Revision 1.4 2004/07/28 15:05:43 reddawg
- Major:
- Pages now have strict security enforcement.
- Many null dereferences have been resolved.
- When apps loaded permissions set for pages rw and ro
-
- Revision 1.3 2004/07/20 22:29:55 reddawg
- assert: remade assert
-
- Revision 1.2 2004/06/10 22:23:56 reddawg
- Volatiles
-
- Revision 1.1.1.1 2004/04/15 12:06:53 reddawg
- UbixOS v1.0
-
- Revision 1.6 2004/04/13 16:36:34 reddawg
- Changed our copyright, it is all now under a BSD-Style license
-
- END
- ***/
-
diff --git a/sys/vmm/unmappage.c b/sys/vmm/unmappage.c
index b89ddc0..bfb0cfd 100644
--- a/sys/vmm/unmappage.c
+++ b/sys/vmm/unmappage.c
@@ -45,9 +45,9 @@
To Create A New Virtual Space So Now It Has A Flag
************************************************************************/
-void vmm_unmapPage(uInt32 pageAddr, int flags) {
+void vmm_unmapPage(uint32_t pageAddr, int flags) {
int pageDirectoryIndex = 0, pageTableIndex = 0;
- uInt32 *pageTable = 0x0;
+ uint32_t *pageTable = 0x0;
/* Get The Index To The Page Directory */
pageDirectoryIndex = (pageAddr >> 22);
@@ -56,22 +56,25 @@
pageTableIndex = ((pageAddr >> 12) & 0x3FF);
/* Set pageTable To The Virtual Address Of Table */
- pageTable = (uInt32 *) (PT_BASE_ADDR + (0x1000 * pageDirectoryIndex));
+ pageTable = (uint32_t *) (PT_BASE_ADDR + (0x1000 * pageDirectoryIndex));
+
/* Free The Physical Page If Flags Is 0 */
if (flags == 0) {
- /*
- * This is temp i think its still an issue clearVirtualPage(pageAddr);
- * freePage((uInt32)(pageTable[pageTableIndex] & 0xFFFFF000));
- */
+ // FIXME This is temp i think its still an issue clearVirtualPage(pageAddr);
+ //freePage((uInt32)(pageTable[pageTableIndex] & 0xFFFFF000));
+
}
+
/* Unmap The Page */
pageTable[pageTableIndex] = 0x0;
+
/* Rehash The Page Directory */
asm volatile(
"movl %cr3,%eax\n"
"movl %eax,%cr3\n"
);
+
/* Return */
return;
}
diff --git a/sys/vmm/vmm_init.c b/sys/vmm/vmm_init.c
index 379bff4..85fab6b 100644
--- a/sys/vmm/vmm_init.c
+++ b/sys/vmm/vmm_init.c
@@ -46,8 +46,3 @@
return (0x0);
}
-
-/***
- END
- ***/
-
diff --git a/sys/vmm/vmm_memory.c b/sys/vmm/vmm_memory.c
index 4db1487..3792ffc 100644
--- a/sys/vmm/vmm_memory.c
+++ b/sys/vmm/vmm_memory.c
@@ -38,7 +38,7 @@
//MrOlsen (2016-01-11) NOTE: Need to Seperate Out CPU Specific Stuff Over Time
#include
-static uInt32 freePages = 0;
+static uint32_t freePages = 0;
static struct spinLock vmmSpinLock = SPIN_LOCK_INITIALIZER;
static struct spinLock vmmCowSpinLock = SPIN_LOCK_INITIALIZER;
@@ -69,7 +69,7 @@
vmmMemoryMap[i].cowCounter = 0x0;
vmmMemoryMap[i].status = memNotavail;
vmmMemoryMap[i].pid = vmmID;
- vmmMemoryMap[i].pageAddr = i * 4096;
+ vmmMemoryMap[i].pageAddr = i * PAGE_SIZE;
}
/* Calculate Start Of Free Memory */
@@ -127,6 +127,7 @@
/* Save The State Of Register CR0 */
cr0 = rcr0();
+
/*
asm volatile (
"movl %%cr0, %%ebx\n"
@@ -206,7 +207,7 @@
asm("nop");
/* Return Amount Of Memory In Pages */
- return ((memKb * 1024 * 1024) / 4096);
+ return ((memKb * 1024 * 1024) / PAGE_SIZE);
}
/************************************************************************
@@ -261,7 +262,8 @@
Notes:
************************************************************************/
-int freePage(uInt32 pageAddr) {
+int freePage(uint32_t pageAddr) {
+
int pageIndex = 0x0;
assert((pageAddr & 0xFFF) == 0x0);
spinLock(&vmmSpinLock);
@@ -271,18 +273,23 @@
/* Check If Page COW Is Greater Then 0 If It Is Dec It If Not Free It */
if (vmmMemoryMap[pageIndex].cowCounter == 0) {
+
/* Set Page As Avail So It Can Be Used Again */
vmmMemoryMap[pageIndex].status = memAvail;
vmmMemoryMap[pageIndex].cowCounter = 0x0;
vmmMemoryMap[pageIndex].pid = -2;
freePages++;
systemVitals->freePages = freePages;
+
}
else {
+
/* Adjust The COW Counter */
- adjustCowCounter(((uInt32) vmmMemoryMap[pageIndex].pageAddr), -1);
+ adjustCowCounter(((uint32_t) vmmMemoryMap[pageIndex].pageAddr), -1);
+
}
spinUnlock(&vmmSpinLock);
+
/* Return */
return (0);
}
@@ -306,13 +313,18 @@
/* Adjust COW Counter */
vmmMemoryMap[vmmMemoryMapIndex].cowCounter += adjustment;
- if (vmmMemoryMap[vmmMemoryMapIndex].cowCounter == 0) {
+ if (vmmMemoryMap[vmmMemoryMapIndex].cowCounter <= 0) {
+
+ if (vmmMemoryMap[vmmMemoryMapIndex].cowCounter < 0)
+ kprintf("ERROR: Why is COW less than 0");
+
vmmMemoryMap[vmmMemoryMapIndex].cowCounter = 0x0;
vmmMemoryMap[vmmMemoryMapIndex].pid = vmmID;
vmmMemoryMap[vmmMemoryMapIndex].status = memAvail;
freePages++;
systemVitals->freePages = freePages;
}
+
spinUnlock(&vmmCowSpinLock);
/* Return */
return (0);
@@ -320,7 +332,7 @@
/************************************************************************
- Function: void vmmFreeProcessPages(pid_t pid);
+ Function: void vmm_freeProcessPages(pid_t pid);
Description: This Function Will Free Up Memory For The Exiting Process
@@ -329,21 +341,30 @@
08/04/02 - Added Checking For COW Pages First
************************************************************************/
+
+/* TODO: This can be greatly immproved for performance but it gets the job done */
void vmm_freeProcessPages(pidType pid) {
int i = 0, x = 0;
- uInt32 *tmpPageTable = 0x0;
- uInt32 *tmpPageDir = (uInt32 *) PD_BASE_ADDR;
+ uint32_t *tmpPageTable = 0x0;
+ uint32_t *tmpPageDir = (uInt32 *) PD_BASE_ADDR;
+
spinLock(&vmmSpinLock);
+
/* Check Page Directory For An Avail Page Table */
- for (i = 0; i <= 0x300; i++) {
+ //NOTE: Thie cleans all memory space up to kernel space
+ for (i = 0; i < (PAGE_SIZE - (PAGE_SIZE / 4)); i++) {
+
if (tmpPageDir[i] != 0) {
+
/* Set Up Page Table Pointer */
- tmpPageTable = (uInt32 *) (PT_BASE_ADDR + (i * 0x1000));
+ tmpPageTable = (uint32_t *) (PT_BASE_ADDR + (i * PAGE_SIZE));
+
/* Check The Page Table For COW Pages */
for (x = 0; x < PD_ENTRIES; x++) {
+
/* If The Page Is COW Adjust COW Counter */
- if (((uInt32) tmpPageTable[x] & PAGE_COW) == PAGE_COW) {
- adjustCowCounter(((uInt32) tmpPageTable[x] & 0xFFFFF000), -1);
+ if (((uint32_t) tmpPageTable[x] & PAGE_COW) == PAGE_COW) {
+ adjustCowCounter(((uint32_t) tmpPageTable[x] & 0xFFFFF000), -1);
}
}
}
@@ -362,6 +383,7 @@
}
}
}
+
/* Return */
spinUnlock(&vmmSpinLock);
return;