Compare commits
3 Commits
607fcc7121
...
fe6dfbc1c6
Author | SHA1 | Date | |
---|---|---|---|
|
fe6dfbc1c6 | ||
|
7b953e625e | ||
|
026618a730 |
@ -36,7 +36,7 @@ void idleThread(void *arg)
|
||||
{
|
||||
(void)arg;
|
||||
while (1) {
|
||||
VGAPrintf(GREEN, BLACK, 0, VGA_HEIGHT - 1, "%d", (jiffies / HZ));
|
||||
VGAPrintf(GREEN, BLACK, 0, VGA_HEIGHT - 1, "%d allocated %d, mapped %d", (jiffies / HZ), getNbAllocatedPage(), getNbMappedPage());
|
||||
threadYield();
|
||||
}
|
||||
}
|
||||
|
@ -269,7 +269,6 @@ uaddr_t sysBrk(struct uAddrSpace *as, uaddr_t newHeapTop)
|
||||
incSize = ALIGN(newHeapTop - (as->heapStart + as->heapSize), PAGE_SIZE);
|
||||
|
||||
if (incSize < 0){
|
||||
//TODO how to free allocated page by uAddrSpaceHeapCheckNAlloc
|
||||
return as->heapStart + as->heapSize;
|
||||
}
|
||||
|
||||
@ -317,6 +316,17 @@ free_ppage:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static struct uAddrVirtualReg *uAddrSpaceMergeVr(struct uAddrVirtualReg *prev,
|
||||
struct uAddrVirtualReg *next)
|
||||
{
|
||||
if (prev && next && prev->addr + prev->size == next->addr && prev->right == next->right &&
|
||||
prev->res == next->res && prev->flags == next->flags && prev->offset == next->offset) {
|
||||
prev->size += next->size;
|
||||
return next;
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int uAddrSpaceMmap(struct uAddrSpace *as, uaddr_t *uaddr, size_t size, uint32_t rights,
|
||||
uint32_t flags, struct mappedRessource *res, uint32_t offset )
|
||||
{
|
||||
@ -363,16 +373,36 @@ int uAddrSpaceMmap(struct uAddrSpace *as, uaddr_t *uaddr, size_t size, uint32_t
|
||||
reg->right = rights;
|
||||
reg->res = res;
|
||||
reg->offset = offset;
|
||||
// TODO merge it with prev/next one
|
||||
|
||||
// keep the AddrSpace list sorted
|
||||
struct uAddrVirtualReg *prev = findVirtualRegionBeforeAddr(as, hint_uaddr);
|
||||
if (prev)
|
||||
bool_t regIsNew = TRUE;
|
||||
if (prev) {
|
||||
struct uAddrVirtualReg *toFree = uAddrSpaceMergeVr(prev, reg);
|
||||
if (toFree) {
|
||||
pr_devel("Merge VR with prev\n");
|
||||
reg = prev;
|
||||
regIsNew = FALSE;
|
||||
free(toFree);
|
||||
}
|
||||
toFree = uAddrSpaceMergeVr(reg, prev->nextInAddrSpace);
|
||||
if (toFree) {
|
||||
pr_devel("Merge VR with next\n");
|
||||
regIsNew = FALSE;
|
||||
if (toFree->res && toFree->res->ops && toFree->res->ops->close)
|
||||
toFree->res->ops->close(toFree);
|
||||
list_delete_named(as->listVirtualReg, toFree, prevInAddrSpace, nextInAddrSpace);
|
||||
list_delete_named(toFree->res->listVirtualReg, toFree, prevInMappedRes,
|
||||
nextInMappedRes);
|
||||
free(toFree);
|
||||
}
|
||||
if (regIsNew)
|
||||
list_insert_after_named(as->listVirtualReg, prev, reg, prevInAddrSpace,
|
||||
nextInAddrSpace);
|
||||
else
|
||||
} else
|
||||
list_add_tail_named(as->listVirtualReg, reg, prevInAddrSpace, nextInAddrSpace);
|
||||
|
||||
if (regIsNew) {
|
||||
list_add_tail_named(reg->res->listVirtualReg, reg, prevInMappedRes, nextInMappedRes);
|
||||
if (res->onResMapped) {
|
||||
int cbret = res->onResMapped(reg);
|
||||
@ -384,6 +414,7 @@ int uAddrSpaceMmap(struct uAddrSpace *as, uaddr_t *uaddr, size_t size, uint32_t
|
||||
|
||||
if (res->ops->open)
|
||||
res->ops->open(reg);
|
||||
}
|
||||
|
||||
*uaddr = hint_uaddr;
|
||||
|
||||
|
37
userspace/errno.h
Normal file
37
userspace/errno.h
Normal file
@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
extern int errno;
|
||||
|
||||
#define EPERM 1 /* Operation not permitted */
|
||||
#define ENOENT 2 /* No such file or directory */
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Interrupted system call */
|
||||
#define EIO 5 /* I/O error */
|
||||
#define ENXIO 6 /* No such device or address */
|
||||
#define E2BIG 7 /* Argument list too long */
|
||||
#define ENOEXEC 8 /* Exec format error */
|
||||
#define EBADF 9 /* Bad file number */
|
||||
#define ECHILD 10 /* No child processes */
|
||||
#define EAGAIN 11 /* Try again */
|
||||
#define ENOMEM 12 /* Out of memory */
|
||||
#define EACCES 13 /* Permission denied */
|
||||
#define EFAULT 14 /* Bad address */
|
||||
#define ENOTBLK 15 /* Block device required */
|
||||
#define EBUSY 16 /* Device or resource busy */
|
||||
#define EEXIST 17 /* File exists */
|
||||
#define EXDEV 18 /* Cross-device link */
|
||||
#define ENODEV 19 /* No such device */
|
||||
#define ENOTDIR 20 /* Not a directory */
|
||||
#define EISDIR 21 /* Is a directory */
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define ENFILE 23 /* File table overflow */
|
||||
#define EMFILE 24 /* Too many open files */
|
||||
#define ENOTTY 25 /* Not a typewriter */
|
||||
#define ETXTBSY 26 /* Text file busy */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Illegal seek */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EMLINK 31 /* Too many links */
|
||||
#define EPIPE 32 /* Broken pipe */
|
||||
#define EDOM 33 /* Math argument out of domain of func */
|
||||
#define ERANGE 34 /* Math result not representable */
|
Loading…
Reference in New Issue
Block a user