Skip to content
Snippets Groups Projects
Commit f6c63418 authored by Peter Ogden's avatar Peter Ogden Committed by Graham Schelle
Browse files

Fix issue with SDSoC constructor being called multiple times (#617)

parent c0f45c87
No related branches found
No related tags found
No related merge requests found
ARCH := $(shell getconf LONG_BIT)
SDSLIB := libsds_lib_$(ARCH).a
all: libsds_lib.so
all: libsds_lib.so libsds_internal.so
.PHONY: all
libsds_lib.so:
gcc wrapper.c -fPIC -shared -rdynamic -o libsds_lib.so -Wl,--whole-archive libsds_lib_$(ARCH).a -l pthread -Wl,--no-whole-archive
libsds_lib.so: wrapper.c libsds_internal.so
gcc wrapper.c -fPIC -shared -rdynamic -o libsds_lib.so -lpthread -ldl -L. -lsds_internal
libsds_internal.so: $(SDSLIB)
gcc -shared -rdynamic -o libsds_internal.so -Wl,--whole-archive $(SDSLIB) -Wl,--no-whole-archive
clean:
-rm -f *.so
install: libsds_lib.so
install: libsds_lib.so libsds_internal.so libxlnk_cma.h
cp -avf libsds_lib.so /usr/lib/
cp -avf libsds_internal.so /usr/lib/
cp -arvf libxlnk_cma.h /usr/include/
#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include "libxlnk_cma.h"
#include <linux/ioctl.h>
#include <errno.h>
#include <dlfcn.h>
#define RESET_IOCTL _IOWR('X', 101, unsigned long)
......@@ -15,9 +17,30 @@ void sds_free(void*);
void *sds_mmap(void *phy_addr, size_t size, void *virtual_addr);
void sds_munmap(void *virtal_addr);
/* CF helper functions */
void cf_xlnk_open(int last);
void cf_xlnk_init(int arg);
int cf_xlnk_open(int last) {
static void (*next_ptr)(int) = NULL;
if (!next_ptr) {
*(void**)(&next_ptr) = dlsym(RTLD_NEXT, "cf_xlnk_open");
next_ptr(1);
}
}
void cf_xlnk_init(int first) {
static void (*next_ptr)(int) = NULL;
if (!next_ptr) {
*(void**)(&next_ptr) = dlsym(RTLD_NEXT, "cf_xlnk_init");
next_ptr(1);
}
}
void cf_context_init(void) {
static void (*next_ptr)(void) = NULL;
if (!next_ptr) {
*(void**)(&next_ptr) = dlsym(RTLD_NEXT, "cf_context_init");
next_ptr();
}
}
/* Functional prototpes from xlnk */
......@@ -96,7 +119,9 @@ void _xlnk_reset() {
__attribute__((constructor))
void open_xlnk(void) {
cf_context_init();
cf_xlnk_open(1);
cf_xlnk_init(1);
}
void cma_flush_cache(void* buf, unsigned int phys_addr, int size) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment