Skip to content

Commit

Permalink
Remove offs_t from log and vm subsystems
Browse files Browse the repository at this point in the history
JIRA: RTOS-665
  • Loading branch information
badochov committed Nov 2, 2023
1 parent 39b0e4e commit 4d32462
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 41 deletions.
2 changes: 2 additions & 0 deletions hal/armv7a/arch/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ typedef u32 addr_t;
typedef u32 cycles_t;

typedef u64 usec_t;
/* FIXME: offs_t should be eradicated */
typedef s64 offs_t;
typedef offs_t off_t;

typedef unsigned int size_t;
typedef unsigned long long time_t;
Expand Down
2 changes: 2 additions & 0 deletions hal/armv7m/arch/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ typedef long long s64;
typedef u32 addr_t;
typedef u32 cycles_t;

/* FIXME: offs_t should be eradicated */
typedef s64 offs_t;
typedef offs_t off_t;

typedef unsigned int size_t;
typedef unsigned long long time_t;
Expand Down
2 changes: 2 additions & 0 deletions hal/armv8m/arch/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ typedef long long s64;
typedef u32 addr_t;
typedef u32 cycles_t;

/* FIXME: offs_t should be eradicated */
typedef s64 offs_t;
typedef offs_t off_t;

typedef unsigned int size_t;
typedef unsigned long long time_t;
Expand Down
2 changes: 2 additions & 0 deletions hal/ia32/arch/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ typedef u32 addr_t;
typedef u64 cycles_t;

typedef u64 usec_t;
/* FIXME: offs_t should be eradicated */
typedef s64 offs_t;
typedef offs_t off_t;

typedef unsigned int size_t;
typedef unsigned long long time_t;
Expand Down
2 changes: 2 additions & 0 deletions hal/riscv64/arch/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ typedef u64 addr_t;
typedef u64 cycles_t;

typedef u64 usec_t;
/* FIXME: offs_t should be eradicated */
typedef s64 offs_t;
typedef offs_t off_t;

typedef unsigned long size_t;
typedef unsigned long long time_t;
Expand Down
2 changes: 2 additions & 0 deletions hal/sparcv8leon3/arch/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ typedef u32 addr_t;
typedef u64 cycles_t;

typedef u64 usec_t;
/* FIXME: offs_t should be eradicated */
typedef s64 offs_t;
typedef offs_t off_t;

typedef unsigned int size_t;
typedef unsigned long long time_t;
Expand Down
2 changes: 0 additions & 2 deletions include/posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ typedef int ino_t; /* FIXME: should be unsigned long long to encode id_t? */
typedef int nlink_t;
typedef int blksize_t;
typedef long long blkcnt_t;
typedef long long off64_t;
typedef off64_t off_t;


struct timespec {
Expand Down
2 changes: 1 addition & 1 deletion include/sysinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ typedef struct _entryinfo_t {

unsigned char flags;
unsigned char prot;
offs_t offs;
off_t offs;

enum { OBJECT_ANONYMOUS, OBJECT_MEMORY, OBJECT_OID } object;
oid_t oid;
Expand Down
8 changes: 4 additions & 4 deletions log/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ typedef struct _log_rmsg_t {


typedef struct _log_reader_t {
offs_t ridx;
off_t ridx;
pid_t pid;
unsigned nonblocking;
log_rmsg_t *msgs;
Expand All @@ -54,8 +54,8 @@ typedef struct _log_reader_t {

static struct {
char buf[KERNEL_LOG_SIZE];
offs_t head;
offs_t tail;
off_t head;
off_t tail;
lock_t lock;
log_reader_t *readers;
volatile int updated;
Expand Down Expand Up @@ -87,7 +87,7 @@ static void _log_push(char c)
}


static char _log_getc(offs_t off)
static char _log_getc(off_t off)
{
return log_common.buf[off % KERNEL_LOG_SIZE];
}
Expand Down
8 changes: 4 additions & 4 deletions proc/name.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ int proc_unlink(oid_t dir, oid_t oid, const char *name)
}


int proc_read(oid_t oid, offs_t offs, void *buf, size_t sz, unsigned mode)
int proc_read(oid_t oid, off_t offs, void *buf, size_t sz, unsigned mode)
{
int err;
msg_t *msg = vm_kmalloc(sizeof(msg_t));
Expand Down Expand Up @@ -423,7 +423,7 @@ int proc_read(oid_t oid, offs_t offs, void *buf, size_t sz, unsigned mode)
}


int proc_write(oid_t oid, offs_t offs, void *buf, size_t sz, unsigned mode)
int proc_write(oid_t oid, off_t offs, void *buf, size_t sz, unsigned mode)
{
int err;
msg_t *msg = vm_kmalloc(sizeof(msg_t));
Expand Down Expand Up @@ -452,9 +452,9 @@ int proc_write(oid_t oid, offs_t offs, void *buf, size_t sz, unsigned mode)
}


offs_t proc_size(oid_t oid)
off_t proc_size(oid_t oid)
{
offs_t err;
off_t err;
msg_t *msg = vm_kmalloc(sizeof(msg_t));

if (msg == NULL)
Expand Down
6 changes: 3 additions & 3 deletions proc/name.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extern int proc_portLookup(const char *name, oid_t *file, oid_t *dev);
extern int proc_lookup(const char *name, oid_t *file, oid_t *dev);


extern int proc_read(oid_t oid, offs_t offs, void *buf, size_t sz, unsigned mode);
extern int proc_read(oid_t oid, off_t offs, void *buf, size_t sz, unsigned mode);


extern int proc_link(oid_t dir, oid_t oid, const char *name);
Expand All @@ -85,10 +85,10 @@ extern int proc_close(oid_t oid, unsigned mode);
extern int proc_open(oid_t oid, unsigned mode);


extern offs_t proc_size(oid_t oid);
extern off_t proc_size(oid_t oid);


extern int proc_write(oid_t oid, offs_t offs, void *buf, size_t sz, unsigned mode);
extern int proc_write(oid_t oid, off_t offs, void *buf, size_t sz, unsigned mode);


extern void _name_init(void);
Expand Down
20 changes: 10 additions & 10 deletions proc/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ typedef struct {
thread_t *parent;

vm_object_t *object;
offs_t offset;
off_t offset;
size_t size;
vm_map_t *map;
vm_map_t *imap;
Expand Down Expand Up @@ -416,7 +416,7 @@ static int process_validateElf32(void *iehdr, size_t size)
char *snameTab;
size_t memsz, filesz;
unsigned i, misalign;
offs_t offs;
off_t offs;

if (size < sizeof(*ehdr)) {
return -ENOEXEC;
Expand Down Expand Up @@ -489,7 +489,7 @@ static int process_validateElf64(void *iehdr, size_t size)
char *snameTab;
size_t memsz, filesz;
unsigned i, misalign;
offs_t offs;
off_t offs;

if (size < sizeof(*ehdr)) {
return -ENOEXEC;
Expand Down Expand Up @@ -552,15 +552,15 @@ static int process_validateElf64(void *iehdr, size_t size)


/* TODO - adding error handling and unmapping of already mapped segments */
int process_load32(vm_map_t *map, vm_object_t *o, offs_t base, void *iehdr, size_t size, size_t *ustacksz, hal_tls_t *tls, ptr_t *tbssAddr)
int process_load32(vm_map_t *map, vm_object_t *o, off_t base, void *iehdr, size_t size, size_t *ustacksz, hal_tls_t *tls, ptr_t *tbssAddr)
{
void *vaddr;
size_t memsz, filesz;
Elf32_Ehdr *ehdr = iehdr;
Elf32_Phdr *phdr;
Elf32_Shdr *shdr, *shstrshdr;
unsigned i, prot, flags, misalign;
offs_t offs;
off_t offs;
char *snameTab;

if (process_validateElf32(iehdr, size) < 0) {
Expand Down Expand Up @@ -635,15 +635,15 @@ int process_load32(vm_map_t *map, vm_object_t *o, offs_t base, void *iehdr, size
}


int process_load64(vm_map_t *map, vm_object_t *o, offs_t base, void *iehdr, size_t size, size_t *ustacksz, hal_tls_t *tls, ptr_t *tbssAddr)
int process_load64(vm_map_t *map, vm_object_t *o, off_t base, void *iehdr, size_t size, size_t *ustacksz, hal_tls_t *tls, ptr_t *tbssAddr)
{
void *vaddr;
size_t memsz, filesz;
Elf64_Ehdr *ehdr = iehdr;
Elf64_Phdr *phdr;
Elf64_Shdr *shdr, *shstrshdr;
unsigned i, prot, flags, misalign;
offs_t offs;
off_t offs;
char *snameTab;

if (process_validateElf64(iehdr, size) < 0) {
Expand Down Expand Up @@ -718,7 +718,7 @@ int process_load64(vm_map_t *map, vm_object_t *o, offs_t base, void *iehdr, size
}


int process_load(process_t *process, vm_object_t *o, offs_t base, size_t size, void **ustack, void **entry)
int process_load(process_t *process, vm_object_t *o, off_t base, size_t size, void **ustack, void **entry)
{
void *stack;
Elf64_Ehdr *ehdr;
Expand Down Expand Up @@ -807,7 +807,7 @@ static int process_relocate(struct _reloc *reloc, size_t relocsz, char **addr)
}


int process_load(process_t *process, vm_object_t *o, offs_t base, size_t size, void **ustack, void **entry)
int process_load(process_t *process, vm_object_t *o, off_t base, size_t size, void **ustack, void **entry)
{
void *stack, *paddr;
Elf32_Ehdr *ehdr;
Expand Down Expand Up @@ -1236,7 +1236,7 @@ static void proc_spawnThread(void *arg)
}


int proc_spawn(vm_object_t *object, vm_map_t *imap, vm_map_t *map, offs_t offset, size_t size, const char *path, char **argv, char **envp)
int proc_spawn(vm_object_t *object, vm_map_t *imap, vm_map_t *map, off_t offset, size_t size, const char *path, char **argv, char **envp)
{
int pid;
process_spawn_t spawn;
Expand Down
4 changes: 2 additions & 2 deletions syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ void *syscalls_mmap(void *ustack)
size_t size;
int prot, flags;
oid_t *oid;
offs_t offs;
off_t offs;
vm_object_t *o;

GETFROMSTACK(ustack, void *, vaddr, 0);
GETFROMSTACK(ustack, size_t, size, 1);
GETFROMSTACK(ustack, int, prot, 2);
GETFROMSTACK(ustack, int, flags, 3);
GETFROMSTACK(ustack, oid_t *, oid, 4);
GETFROMSTACK(ustack, offs_t, offs, 5);
GETFROMSTACK(ustack, off_t, offs, 5);

if (oid == OID_NULL) {
o = NULL;
Expand Down
2 changes: 1 addition & 1 deletion vm/amap.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static int amap_unmap(vm_map_t *map, void *v)
}


page_t *amap_page(vm_map_t *map, amap_t *amap, vm_object_t *o, void *vaddr, int aoffs, offs_t offs, int prot)
page_t *amap_page(vm_map_t *map, amap_t *amap, vm_object_t *o, void *vaddr, int aoffs, off_t offs, int prot)
{
page_t *p = NULL;
anon_t *a;
Expand Down
2 changes: 1 addition & 1 deletion vm/amap.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ typedef struct _amap_t {
} amap_t;


extern page_t *amap_page(struct _vm_map_t *map, amap_t *amap, struct _vm_object_t *o, void *vaddr, int aoffs, offs_t offs, int prot);
extern page_t *amap_page(struct _vm_map_t *map, amap_t *amap, struct _vm_object_t *o, void *vaddr, int aoffs, off_t offs, int prot);


extern void amap_clear(amap_t *amap, size_t offset, size_t size);
Expand Down
8 changes: 4 additions & 4 deletions vm/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void *_map_find(vm_map_t *map, void *vaddr, size_t size, map_entry_t **prev, map
}


static void *_map_map(vm_map_t *map, void *vaddr, process_t *proc, size_t size, u8 prot, vm_object_t *o, offs_t offs, u8 flags, map_entry_t **entry)
static void *_map_map(vm_map_t *map, void *vaddr, process_t *proc, size_t size, u8 prot, vm_object_t *o, off_t offs, u8 flags, map_entry_t **entry)
{
void *v;
map_entry_t *prev, *next, *e;
Expand Down Expand Up @@ -441,7 +441,7 @@ int _vm_munmap(vm_map_t *map, void *vaddr, size_t size)
}


void *_vm_mmap(vm_map_t *map, void *vaddr, page_t *p, size_t size, u8 prot, vm_object_t *o, offs_t offs, u8 flags)
void *_vm_mmap(vm_map_t *map, void *vaddr, page_t *p, size_t size, u8 prot, vm_object_t *o, off_t offs, u8 flags)
{
int attr = PROT_NONE;
void *w;
Expand Down Expand Up @@ -506,7 +506,7 @@ void *_vm_mmap(vm_map_t *map, void *vaddr, page_t *p, size_t size, u8 prot, vm_o
}


void *vm_mmap(vm_map_t *map, void *vaddr, page_t *p, size_t size, u8 prot, vm_object_t *o, offs_t offs, u8 flags)
void *vm_mmap(vm_map_t *map, void *vaddr, page_t *p, size_t size, u8 prot, vm_object_t *o, off_t offs, u8 flags)
{
if (map == NULL)
map = map_common.kmap;
Expand All @@ -522,7 +522,7 @@ void *vm_mmap(vm_map_t *map, void *vaddr, page_t *p, size_t size, u8 prot, vm_ob
* Fault routines
*/

int vm_lockVerify(vm_map_t *map, amap_t **amap, vm_object_t *o, void *vaddr, offs_t offs)
int vm_lockVerify(vm_map_t *map, amap_t **amap, vm_object_t *o, void *vaddr, off_t offs)
{
map_entry_t t, *e;

Expand Down
8 changes: 4 additions & 4 deletions vm/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ typedef struct _map_entry_t {
unsigned short flags;
unsigned short prot;
struct _vm_object_t *object;
offs_t offs;
off_t offs;
} map_entry_t;


extern void *vm_mapFind(vm_map_t *map, void *vaddr, size_t size, u8 flags, u8 prot);


extern void *vm_mmap(vm_map_t *map, void *vaddr, page_t *p, size_t size, u8 prot, struct _vm_object_t *o, offs_t offs, u8 flags);
extern void *vm_mmap(vm_map_t *map, void *vaddr, page_t *p, size_t size, u8 prot, struct _vm_object_t *o, off_t offs, u8 flags);


extern void *_vm_mmap(vm_map_t *map, void *vaddr, page_t *p, size_t size, u8 prot, struct _vm_object_t *o, offs_t offs, u8 flags);
extern void *_vm_mmap(vm_map_t *map, void *vaddr, page_t *p, size_t size, u8 prot, struct _vm_object_t *o, off_t offs, u8 flags);


extern int vm_mapForce(vm_map_t *map, void *vaddr, int prot);
Expand All @@ -87,7 +87,7 @@ extern int vm_mapForce(vm_map_t *map, void *vaddr, int prot);
extern int vm_mapFlags(vm_map_t *map, void *vaddr);


extern int vm_lockVerify(vm_map_t *map, struct _amap_t **amap, struct _vm_object_t *o, void *vaddr, offs_t offs);
extern int vm_lockVerify(vm_map_t *map, struct _amap_t **amap, struct _vm_object_t *o, void *vaddr, off_t offs);


extern int vm_munmap(vm_map_t *map, void *vaddr, size_t size);
Expand Down
8 changes: 4 additions & 4 deletions vm/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int vm_objectGet(vm_object_t **o, oid_t oid)
{
vm_object_t t, *no = NULL;
size_t i, n;
offs_t sz;
off_t sz;
int err = -ENOMEM;

t.oid.port = oid.port;
Expand All @@ -72,7 +72,7 @@ int vm_objectGet(vm_object_t **o, oid_t oid)
if (sz < 0) {
err = (int)sz;
}
else if ((sizeof(offs_t) <= sizeof(size_t)) || (sz <= (offs_t)((size_t)-1))) {
else if ((sizeof(off_t) <= sizeof(size_t)) || (sz <= (off_t)((size_t)-1))) {
n = round_page((size_t)sz) / SIZE_PAGE;
no = (vm_object_t *)vm_kmalloc(sizeof(vm_object_t) + n * sizeof(page_t *));
}
Expand Down Expand Up @@ -156,7 +156,7 @@ int vm_objectPut(vm_object_t *o)
}


static page_t *object_fetch(oid_t oid, offs_t offs)
static page_t *object_fetch(oid_t oid, off_t offs)
{
page_t *p;
void *v;
Expand Down Expand Up @@ -189,7 +189,7 @@ static page_t *object_fetch(oid_t oid, offs_t offs)
}


page_t *vm_objectPage(vm_map_t *map, amap_t **amap, vm_object_t *o, void *vaddr, offs_t offs)
page_t *vm_objectPage(vm_map_t *map, amap_t **amap, vm_object_t *o, void *vaddr, off_t offs)
{
page_t *p;

Expand Down
2 changes: 1 addition & 1 deletion vm/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extern int vm_objectGet(vm_object_t **o, oid_t oid);
extern int vm_objectPut(vm_object_t *o);


extern page_t *vm_objectPage(struct _vm_map_t *map, amap_t **amap, vm_object_t *o, void *vaddr, offs_t offs);
extern page_t *vm_objectPage(struct _vm_map_t *map, amap_t **amap, vm_object_t *o, void *vaddr, off_t offs);


extern vm_object_t *vm_objectContiguous(size_t size);
Expand Down

0 comments on commit 4d32462

Please sign in to comment.