gct
gct

Reputation: 14583

How to switch to real mode in a linux driver

I've got an intel-based SBC that I'm using in an embedded application. It's got a Digital IO (DIO) port attached to a Fintek Super I/O chip. I want to be able to set the bits on the output lines of this port to control some other hardware.

Fortunately, the manufacturer's BIOS comes with a function to do just this:

AX=6F09h
bl=<bits>
int 15h

Unfortunately I'm running 64-bit linux in protected mode. Is there any way I can call that bios interrupt, either from a user-space program or as a kernel driver if need be?

I can alternatively set registers directly on the Fintek chip, but this requires knowing exactly what pins on the chip are connected to the DIO header, and, of course, this changes from board revision to board revision.

Upvotes: 2

Views: 1102

Answers (3)

Dtyree
Dtyree

Reputation: 330

I've shimmed it into the bootloader before for prototypes, but it may not carry over. Either you fix the hw or futz with the chip locations based on "where they've been before".

Upvotes: 0

ninjalj
ninjalj

Reputation: 43748

Your distribution probably has packages for libx86. libx86 uses lrmi (the opposite of DPMI) on x86, and an x86 emulator on x86-64, since AFAIK vm86 mode cannot be used from 64 bits mode.

Upvotes: 2

Griwes
Griwes

Reputation: 9039

First of all, you must ensure that Linux doesn't overwrite memory, where interrupts reside.

You will not be able to get to real mode in any easy and not-breaking OS runtime way. You should find where in memory that interrupt function is and use some kind of emulator to interpret that 16bit machine code and execute 64bit long mode procedures. You can search OSDev Forums and OSDev Wiki to find more on this topic.

(Tip: look for questions about using VESA in protected mode).

Upvotes: 1

Related Questions