Use netbsd <sys/mman.h>

Change-Id: I80e9cffc80140383a6faf692248573c64d282b4a
This commit is contained in:
Ben Gras
2013-11-28 17:51:21 +01:00
committed by Lionel Sambuc
parent 364953ad40
commit 88be7bd333
10 changed files with 99 additions and 100 deletions

View File

@@ -29,18 +29,16 @@ void *minix_mmap_for(endpoint_t forwhom,
int r;
memset(&m, 0, sizeof(m));
m.VMM_ADDR = (vir_bytes) addr;
m.VMM_ADDR = addr;
m.VMM_LEN = len;
m.VMM_PROT = prot;
m.VMM_FLAGS = flags;
m.VMM_FD = fd;
m.VMM_OFFSET_LO = ex64lo(offset);
m.VMM_OFFSET = offset;
m.VMM_FORWHOM = forwhom;
if(forwhom != SELF) {
m.VMM_FLAGS |= MAP_THIRDPARTY;
m.VMM_FORWHOM = forwhom;
} else {
m.VMM_OFFSET_HI = ex64hi(offset);
}
r = _syscall(VM_PROC_NR, VM_MMAP, &m);
@@ -49,11 +47,11 @@ void *minix_mmap_for(endpoint_t forwhom,
return MAP_FAILED;
}
return (void *) m.VMM_RETADDR;
return m.VMM_RETADDR;
}
int minix_vfs_mmap(endpoint_t who, u32_t offset, u32_t len,
dev_t dev, u32_t ino, u16_t fd, u32_t vaddr, u16_t clearend,
int minix_vfs_mmap(endpoint_t who, off_t offset, size_t len,
dev_t dev, ino_t ino, int fd, u32_t vaddr, u16_t clearend,
u16_t flags)
{
message m;
@@ -67,7 +65,8 @@ int minix_vfs_mmap(endpoint_t who, u32_t offset, u32_t len,
m.m_u.m_vm_vfs.vaddr = vaddr;
m.m_u.m_vm_vfs.len = len;
m.m_u.m_vm_vfs.fd = fd;
m.m_u.m_vm_vfs.clearend_and_flags = clearend | flags;
m.m_u.m_vm_vfs.clearend = clearend;
m.m_u.m_vm_vfs.flags = flags;
return _syscall(VM_PROC_NR, VM_VFS_MMAP, &m);
}
@@ -78,12 +77,6 @@ void *minix_mmap(void *addr, size_t len, int prot, int flags,
return minix_mmap_for(SELF, addr, len, prot, flags, fd, offset);
}
void *minix_mmap64(void *addr, size_t len, int prot, int flags,
int fd, u64_t offset)
{
return minix_mmap_for(SELF, addr, len, prot, flags, fd, offset);
}
int minix_munmap(void *addr, size_t len)
{
message m;
@@ -146,7 +139,7 @@ int vm_unmap(endpoint_t endpt, void *addr)
memset(&m, 0, sizeof(m));
m.VMUN_ENDPT = endpt;
m.VMUN_ADDR = (long) addr;
m.VMUN_ADDR = addr;
return _syscall(VM_PROC_NR, VM_SHM_UNMAP, &m);
}

View File

@@ -429,14 +429,14 @@ int block_type; /* INODE_BLOCK, DIRECTORY_BLOCK, or whatever */
* disk immediately if they are dirty.
*/
dev_t dev;
u64_t dev_off;
off_t dev_off;
int r;
if (bp == NULL) return; /* it is easier to check here than in caller */
dev = bp->lmfs_dev;
dev_off = (u64_t) bp->lmfs_blocknr * fs_block_size;
dev_off = (off_t) bp->lmfs_blocknr * fs_block_size;
lowercount(bp);
if (bp->lmfs_count != 0) return; /* block is still in use */
@@ -508,7 +508,7 @@ register struct buf *bp; /* buffer pointer */
* from the cache, it is not clear what the caller could do about it anyway.
*/
int r, op_failed;
u64_t pos;
off_t pos;
dev_t dev = bp->lmfs_dev;
op_failed = 0;
@@ -518,7 +518,7 @@ register struct buf *bp; /* buffer pointer */
ASSERT(bp->lmfs_bytes == fs_block_size);
ASSERT(fs_block_size > 0);
pos = (u64_t)bp->lmfs_blocknr * fs_block_size;
pos = (off_t)bp->lmfs_blocknr * fs_block_size;
if(fs_block_size > PAGE_SIZE) {
#define MAXPAGES 20
vir_bytes blockrem, vaddr = (vir_bytes) bp->data;
@@ -629,7 +629,7 @@ void lmfs_rw_scattered(
register int i;
register iovec_t *iop;
static iovec_t iovec[NR_IOREQS];
u64_t pos;
off_t pos;
int iov_per_block;
int start_in_use = bufs_in_use, start_bufqsize = bufqsize;
@@ -704,7 +704,7 @@ void lmfs_rw_scattered(
assert(nblocks > 0);
assert(niovecs > 0);
pos = (u64_t)bufq[0]->lmfs_blocknr * fs_block_size;
pos = (off_t)bufq[0]->lmfs_blocknr * fs_block_size;
if (rw_flag == READING)
r = bdev_gather(dev, pos, iovec, niovecs, BDEV_NOFLAGS);
else
@@ -941,7 +941,7 @@ int lmfs_do_bpeek(message *m)
{
block_t startblock, b, limitblock;
dev_t dev = m->REQ_DEV;
u64_t extra, pos = make64(m->REQ_SEEK_POS_LO, m->REQ_SEEK_POS_HI);
off_t extra, pos = make64(m->REQ_SEEK_POS_LO, m->REQ_SEEK_POS_HI);
size_t len = m->REQ_NBYTES;
struct buf *bp;

View File

@@ -92,7 +92,6 @@ SRCS+= \
vm_map_phys.c \
vm_memctl.c \
vm_notify_sig.c \
vm_umap.c \
vm_procctl.c \
vm_query_exit.c \
vm_set_priv.c \

View File

@@ -9,8 +9,8 @@
#include <minix/sysutil.h>
#include <machine/vmparam.h>
int vm_cachecall(message *m, int call, void *addr, dev_t dev, u64_t dev_offset,
u64_t ino, u64_t ino_offset, u32_t *flags, int blocksize)
int vm_cachecall(message *m, int call, void *addr, dev_t dev, off_t dev_offset,
ino_t ino, off_t ino_offset, u32_t *flags, int blocksize)
{
if(blocksize % PAGE_SIZE)
panic("blocksize %d should be a multiple of pagesize %d\n",
@@ -28,8 +28,8 @@ int vm_cachecall(message *m, int call, void *addr, dev_t dev, u64_t dev_offset,
assert(dev != NO_DEV);
m->m_u.m_vmmcp.dev_offset_pages = dev_offset/PAGE_SIZE;
m->m_u.m_vmmcp.ino_offset_pages = ino_offset/PAGE_SIZE;
m->m_u.m_vmmcp.dev_offset = dev_offset;
m->m_u.m_vmmcp.ino_offset = ino_offset;
m->m_u.m_vmmcp.ino = ino;
m->m_u.m_vmmcp.block = addr;
m->m_u.m_vmmcp.flags_ptr = flags;
@@ -40,8 +40,8 @@ int vm_cachecall(message *m, int call, void *addr, dev_t dev, u64_t dev_offset,
return _taskcall(VM_PROC_NR, call, m);
}
void *vm_map_cacheblock(dev_t dev, u64_t dev_offset,
u64_t ino, u64_t ino_offset, u32_t *flags, int blocksize)
void *vm_map_cacheblock(dev_t dev, off_t dev_offset,
ino_t ino, off_t ino_offset, u32_t *flags, int blocksize)
{
message m;
@@ -52,8 +52,8 @@ void *vm_map_cacheblock(dev_t dev, u64_t dev_offset,
return m.m_u.m_vmmcp_reply.addr;
}
int vm_set_cacheblock(void *block, dev_t dev, u64_t dev_offset,
u64_t ino, u64_t ino_offset, u32_t *flags, int blocksize)
int vm_set_cacheblock(void *block, dev_t dev, off_t dev_offset,
ino_t ino, off_t ino_offset, u32_t *flags, int blocksize)
{
message m;