Skip to content

Commit

Permalink
Add mmap64 command
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorxda committed May 24, 2024
1 parent 04a765f commit e601d5d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SRC := $(shell find ./ -name '*.c')

divinus:
$(CC) $(SRC) -I src -rdynamic -Wl,--wrap=mmap $(OPT) -o ../$@
$(CC) $(SRC) -I src -rdynamic $(OPT) -o ../$@
9 changes: 5 additions & 4 deletions src/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ float __expf_finite(float x) { return expf(x); }
int __fgetc_unlocked(FILE *stream) { return fgetc(stream); }
double __log_finite(double x) { return log(x); }

void* mmap(void *start, size_t len, int prot, int flags, int fd, uint32_t off) {
void *mmap(void *start, size_t len, int prot, int flags, int fd, uint32_t off) {
return (void*)syscall(SYS_mmap2, start, len, prot, flags, fd, off >> 12);
}

void *mmap64(void *start, size_t len, int prot, int flags, int fd, off_t off) {
return (void*)syscall(SYS_mmap2, start, len, prot, flags, fd, off >> 12);
}
void* __wrap_mmap(void *start, size_t len, int prot, int flags, int fd, uint32_t off) {
return mmap(start, len, prot, flags, fd, off);
}
6 changes: 2 additions & 4 deletions src/hal/support.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "support.h"

extern void* __real_mmap();

void *isp_thread = NULL;
void *venc_thread = NULL;

Expand Down Expand Up @@ -34,7 +32,7 @@ bool hal_registry(unsigned int addr, unsigned int *data, hal_register_op op) {

volatile char *mapped_area;
if (offset != loaded_offset) {
mapped_area = __real_mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, mem_fd, offset);
mapped_area = mmap64(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, mem_fd, offset);
if (mapped_area == MAP_FAILED) {
fprintf(stderr, "hal_registry mmap error: %s (%d)\n",
strerror(errno), errno);
Expand Down Expand Up @@ -116,4 +114,4 @@ void hal_identify(void) {
chnState = (hal_chnstate*)v4_state;
isp_thread = v4_image_thread;
venc_thread = v4_video_thread;
}
}
4 changes: 3 additions & 1 deletion src/hal/support.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ extern void *i6f_encoder_thread(void);
extern hal_chnstate i6f_state[I6F_VENC_CHN_NUM];

bool hal_registry(unsigned int addr, unsigned int *data, hal_register_op op);
void hal_identify(void);
void hal_identify(void);

void *mmap64(void *start, size_t len, int prot, int flags, int fd, off_t off);

0 comments on commit e601d5d

Please sign in to comment.