Compare commits
No commits in common. "fe6dfbc1c639acb0f1d4b48fdca01f10f2d403d4" and "607fcc7121cfb6047ffd90314e2a8b0efac30f0a" have entirely different histories.
fe6dfbc1c6
...
607fcc7121
@ -36,7 +36,7 @@ void idleThread(void *arg)
|
||||
{
|
||||
(void)arg;
|
||||
while (1) {
|
||||
VGAPrintf(GREEN, BLACK, 0, VGA_HEIGHT - 1, "%d allocated %d, mapped %d", (jiffies / HZ), getNbAllocatedPage(), getNbMappedPage());
|
||||
VGAPrintf(GREEN, BLACK, 0, VGA_HEIGHT - 1, "%d", (jiffies / HZ));
|
||||
threadYield();
|
||||
}
|
||||
}
|
||||
|
@ -269,6 +269,7 @@ 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;
|
||||
}
|
||||
|
||||
@ -316,17 +317,6 @@ 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 )
|
||||
{
|
||||
@ -373,49 +363,28 @@ 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);
|
||||
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
|
||||
if (prev)
|
||||
list_insert_after_named(as->listVirtualReg, prev, reg, prevInAddrSpace,
|
||||
nextInAddrSpace);
|
||||
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);
|
||||
if (cbret) {
|
||||
pr_devel("Call back failed on ressource mmaped\n");
|
||||
ret = uAddrSpaceUnmap(as, reg->addr, reg->size);
|
||||
}
|
||||
list_add_tail_named(reg->res->listVirtualReg, reg, prevInMappedRes, nextInMappedRes);
|
||||
if (res->onResMapped) {
|
||||
int cbret = res->onResMapped(reg);
|
||||
if (cbret) {
|
||||
pr_devel("Call back failed on ressource mmaped\n");
|
||||
ret = uAddrSpaceUnmap(as, reg->addr, reg->size);
|
||||
}
|
||||
|
||||
if (res->ops->open)
|
||||
res->ops->open(reg);
|
||||
}
|
||||
|
||||
if (res->ops->open)
|
||||
res->ops->open(reg);
|
||||
|
||||
*uaddr = hint_uaddr;
|
||||
|
||||
return ret;
|
||||
|
@ -1,37 +0,0 @@
|
||||
#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