On 1/14/2014 5:34 AM, andy pugh wrote:
> Someone on the forum is trying to write a driver for some onboard GPIO
> that needs to be enabled via an INT 15. The sample assembler is:
> 
> MOV AX, 6F08H        Sets the digital port as input
> INT 15H                     Initiates the INT 15H
> 
> Is it reasonable/legitimate to do this with inline assembler in a .comp file?
> 
> Having never tried to use inline assembler, what would it look like? I
> guess we need to put ax back to where it was afterwards?
> 
> Is there  a linux system call to achieve the same result?

Not to derail this thread from the "I used to have to enter hex machine
instructions by hand with toggle switches, and it was up-hill both
ways!" reminiscing, but it should be OK to do an INT instruction or make
kernel calls in the setup portion of a HAL component.  Of course the
execution mode and the interrupt need to agree on things like the
current operating context of the CPU (no calling 16-bit BIOS routines
from 32-bit PAE code!).

As for Linux system calls, there's a GPIO sub-system, but it may not be
available on his I/O card.  For I/O pins with Linux drivers that follow
the kernel standards for the GPIO interface, you do something like:

  gpio_number=[kernel gpio pin number, system specific]

  echo ${gpio_number} > /sys/class/gpio/export

...to make a GPIO pin available to user-space (and insure the kernel is
not trying to use it for something), then:

  echo out > /sys/class/gpio/gpio${gpio_number}/direction

To set the pin direction and:

  echo 1 > /sys/class/gpio/gpio${gpio_number}/value
  echo 0 > /sys/class/gpio/gpio${gpio_number}/value
  echo 1 > /sys/class/gpio/gpio${gpio_number}/value
  echo 0 > /sys/class/gpio/gpio${gpio_number}/value
  ...

...to 'wiggle' the pin.

Again, this assumes a somewhat recent kernel and a GPIO device written
in Linux standard fashion.  More details on the kernel GPIO interface
(including methods to access GPIO w/o using sysfs) can be found in the
kernel documentation:

https://www.kernel.org/doc/Documentation/gpio/gpio-legacy.txt

But x86 boards are unlikely to work this way, so it's probably time to
crawl through the Linux driver documentation and code that supports the
hardware in question (assuming a driver is available).

-- 
Charles Steinkuehler
[email protected]

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to