So I have this write function that writes a byte. The fact that it is JNI is not important:
Code:
JNIEXPORT jint JNICALL Java_com_nextbus_signcontroller_mvc_TechnologicHAL_mmapWriteByte
(JNIEnv *env, jclass obj, jint address, jbyte value)
{
/* Use mmap() to map memory, then write byte to address */
off_t page;
volatile unsigned char *start;
int ret;
int fd;
fd = open("/dev/mem", O_RDWR);
if (fd == -1) return -1;
page = address & PAGE_MASK;
start = (unsigned char*)
mmap(0,getpagesize(),PROT_READ|PROT_WRITE,MAP_SHARED,fd,page);
if (start == MAP_FAILED) {
close(fd);
return -1;
}
*(start + (ADDR_MASK & address)) = value;
ret = munmap((void*)start,getpagesize());
close(fd);
return ret;
}
I want this to become a 32-bit write operation
My question is this: is changing this to a 32-bit write operation as easy as changing the 'value' parameter from a jbyte to a jint? How would this work if it were not JNI?
Thanks for any info!
Alex