简体   繁体   中英

PC hardware port access from Java on Linux

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM