I've a C application. This application writes and reads some I/O port addresses.
I think that Java can't access low level I/O address natively. Am I right?
Here is an example of C++ app:
#include <malloc.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <sys/io.h>
int main(int argc, char *argv[])
{
cout << "Refresh watchdog program" << endl;
outb(0x87,0x2E); //Extended Function Mode
outb(0x30,0x2E); //Set Watch Dog Timer Activate
outb(0x01,0x2F);
int reg = inb(0x2f);
outb(reg|0x08, 0x2f);
}
How can I do the same in Java?
I think sun.misc.Unsafe might help you for this. It has methods like
void putAddress(long address, long value)
that may suit your need. To be honest I haven't worked on this but you could know more about it fromhttp://mydailyjava.blogspot.co.uk/2013/12/sunmiscunsafe.html
http://mishadoff.github.io/blog/java-magic-part-4-sun-dot-misc-dot-unsafe/
http://highlyscalable.wordpress.com/2012/02/02/direct-memory-access-in-java/
A small sample program could be found on
http://robaustin.wikidot.com/how-to-write-to-direct-memory-locations-in-java