public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Serial IO focusing
@ 1997-08-20 14:12 mark koi
  1997-08-21 22:56 ` Tim Iverson
  1997-08-22  4:06 ` Fergus Henderson
  0 siblings, 2 replies; 3+ messages in thread
From: mark koi @ 1997-08-20 14:12 UTC (permalink / raw)
  To: gnu-win32

I had a program under DOS which controlled a serial port using a polling

method.  Now I am trying to use gnu-win32, and I see no libraries for
things like outp(), inp().  Can someone steer me in the right direction
for
examples/how-tos for controlling a serial port in WIN95.  The
application
does not have to be windows based.

Thanks and I would appreciate help cause I am lost.

koi@ssa.crane.navy.mil



-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Serial IO focusing
  1997-08-20 14:12 Serial IO focusing mark koi
@ 1997-08-21 22:56 ` Tim Iverson
  1997-08-22  4:06 ` Fergus Henderson
  1 sibling, 0 replies; 3+ messages in thread
From: Tim Iverson @ 1997-08-21 22:56 UTC (permalink / raw)
  To: mark koi; +Cc: gnu-win32

Cygnus may have some of these already coded in their machine.h file, but if
you don't find it there, most folks usually just write their own using
GCC's inline asm; eg. in your very own machine.h file ...

static unsigned char inline
inb (const unsigned short port)
{
	register unsigned char val;

	__asm __volatile ("inb %%dx,%%al" : "=a" (val) : "d" (port));
	return val;
}

If I managed to remember the gas syntax for inb correctly,

{
	int x = inb(0x3f8);
}

Will produce the following assembly

	movw	%dx, $0x3f8
	inb	%dx, %al
	movzbl	%al, -4(%epb)

Or something quite similar -- GCC is smart enough to keep 0x3f8 in a
register and not reload it every time if you're in a loop.  It will also
skip the move to automatic storage if it can and just use the value in AL.

There is some cryptic documentation on inline asm for GCC in the info files.
For the details, you will need to read the source -- particularly the
machine description file in gcc/config/i386/i386.md.  This is the only
place you can find the descriptions for the various register fields (eg.
the "=a") to use in the asm lines.

- Tim

\f
+----------------
| Date: Wed, 20 Aug 1997 16:31:39 -0400
| From: mark koi <koi@ssa.crane.navy.mil>
| To: gnu-win32@cygnus.com
| Subject: Serial IO focusing
| 
| method.  Now I am trying to use gnu-win32, and I see no libraries for
| things like outp(), inp().  Can someone steer me in the right direction
| for examples/how-tos for controlling a serial port in WIN95.  The
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Serial IO focusing
  1997-08-20 14:12 Serial IO focusing mark koi
  1997-08-21 22:56 ` Tim Iverson
@ 1997-08-22  4:06 ` Fergus Henderson
  1 sibling, 0 replies; 3+ messages in thread
From: Fergus Henderson @ 1997-08-22  4:06 UTC (permalink / raw)
  To: mark koi; +Cc: Cygnus GNU-win32 mailing list

mark koi, you wrote:
> I had a program under DOS which controlled a serial port using a polling
> 
> method.  Now I am trying to use gnu-win32, and I see no libraries for
> things like outp(), inp().

I think you probably just need to define these using inline assembler.

#define outb(value, port) \
  ({ __asm__ __volatile__ ("outb %b0,%w1"::"a" (value), "d" (port)); })

#define inb(port) \
  ({ char _v; \
      __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"d" (port)); \
      _v; \
  })

However, I haven't tried this...
I don't know if Windows allows direct access to I/O ports like this.
You might have to write a Windows device driver (VxD).

-- 
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: < http://www.cs.mu.oz.au/~fjh >   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-08-22  4:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-08-20 14:12 Serial IO focusing mark koi
1997-08-21 22:56 ` Tim Iverson
1997-08-22  4:06 ` Fergus Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).