PC hardware port access from Java on Linux

524 views Asked by At

What is the Java-on-Linux equivalent to the C byte-sized PC-architecture hardware port input/output functions?

For output there is outb as in this:

tmp = inb(0x61);
if (tmp != (tmp | 0x01)) 
    outb(0x61, tmp | 0x01);

For input there is inb as in this:

tmp = (inb(0x61) & 0xfe);
outb(0x61, tmp);

Purpose: I want to implement something that imposes less overhead than this:

try { Runtime.getRuntime().exec("beep") } catch (IOException e) {}

as an alternative to sending code 7 (the bell char) to the standard output because that seems to have been aggressively disabled in Ubuntu. Toolkit's beep is also mute.

1

There are 1 answers

7
adelphus On

I think you're barking up the wrong train.

Java is a object-oriented high-level language compiling to a virtual machine architecture. Assembler I/O instructions are hardware processor specific. There is no direct equivalence between the two.

The best you could hope for is to interface your Java code (using pipes, shared memory, sockets, etc) with a native Linux app which performs the required I/O.