parallel port driver

2003-01-27 Thread Robert Millan


Hello!

I wanted to play a bit with driver coding in userspace, and understood that
we don't have any working parallel port driver (was the lpr in mach ever
working?).

So just wrote a simple parallel port driver for the Hurd that works on
userspace. It has some deficiences (see the TODO), but you can safely print
through it. (and if we had a printer daemon, we could even print sanely with
Chair Returns ;))

Please take a look at it. If it looks fine, i can write a patch to integrate
it in Hurd's source.

oh, and thanks Wolfgang for your nice Hurd Hacking guide!

-- 
Robert Millan

"Omnis enim res, quad dando non deficit, dum habetur et non datur,
nondum habetur, quomodo habenda est."

"For if a thing is not diminished by being shared with others, it is
not rightly owned if it is only owned and not shared." 

Aurelius Augustinus (354-430)

/* parport.c - simple parallel port driver

   TODO:
 - select devices properly depending on the node name (parport0...)
 - use ioperm (when available)
 - get it working on oskit-mach (need ioperm)
 - use interrupts not polling (when available)
 - get a replacement for those printf's
 - argp support
 - implement reading (this thing can read can't it?)
 - implement enhanced modes
 - port CUPS, so we can actualy use this crap ;)

   Written by Robert Millan <[EMAIL PROTECTED]>, 2003

   This is based on hurd-one.c. The hurd-one.c source says:

  Written by Wolfgang Jaehrling <[EMAIL PROTECTED]>, 2001

  This is based on hurd/trans/hello.c. The hello.c source says:
Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
Gordon Matzigkeit <[EMAIL PROTECTED]>, 1999
  It also uses parts of hurd/trans/null.c. The null.c source says:
Copyright (C) 1995,96,97,98,99,2001 Free Software Foundation, Inc.
Written by Miles Bader <[EMAIL PROTECTED]>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2, or (at
   your option) any later version.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330,
   Boston, MA  02111-1307  USA */

#define _GNU_SOURCE 1

#include 

#include/* I/O */

#include/* exit () */
#include /* Error numers */
#include /* O_READ etc. */
#include 
#include 

/* we need ioperm working on Mach,
   for now we have this ugly hack */
//define USE_IOPERM

static unsigned short probe_port (unsigned short p);
static void send_char (char c);

static unsigned short base;
#define Rdat base+0x00
#define Rsta base+0x01
#define Rcon base+0x02

/* Trivfs hooks. */
int trivfs_fstype = FSTYPE_MISC;  /* Generic trivfs server */
int trivfs_fsid = 0;  /* Should always be 0 on startup */

int trivfs_allow_open = O_READ | O_WRITE;

/* Actual supported modes: */
int trivfs_support_read  = 0;
int trivfs_support_write = 1;
int trivfs_support_exec  = 0;

/* May do nothing... */
void
trivfs_modify_stat (struct trivfs_protid *cred, io_statbuf_t *st)
{
  /* .. and we do nothing */
}

error_t
trivfs_goaway (struct trivfs_control *cntl, int flags)
{
  exit (EXIT_SUCCESS);
}

error_t
trivfs_S_io_read (trivfs_protid_t cred, mach_port_t reply,
mach_msg_type_name_t replyPoly, data_t *data,
mach_msg_type_number_t *data_len, loff_t offset,
vm_size_t amount)
{
  /* Deny access if they have bad credentials. */
  if (!cred)
return EOPNOTSUPP;
  else if (!(cred->po->openmodes & O_READ))
return EBADF;

  /* Nothing to read yet */

  *data_len = amount;
  return 0;
}

kern_return_t
trivfs_S_io_write (trivfs_protid_t cred, mach_port_t reply,
mach_msg_type_name_t replyPoly, data_t data,
mach_msg_type_number_t datalen, loff_t offset,
vm_size_t *amount)
{
  if (!cred)
return EOPNOTSUPP;
  else if (!(cred->po->openmodes & O_WRITE))
return EBADF;

  int i;

  if (probe_port (0x0378))
base = 0x0378;
  else if (probe_port (0x0278))
base = 0x0278;
  else if (probe_port (0x03bc))
base = 0x03bc;
  else
{
  printf ("No printers found\n");
  exit (1);
}
  printf ("Found printer at port 0x%03x\n", base);  

#ifdef USE_IOPERM
  if (ioperm(base, 3, 1)) {
printf("Could not access %03x-%03x: %s.\n", base, base+3, strerror(errno));
exit(1);
  }
#endif

  /*
Initialise printer:
  strobe = 0
  autofeed   = 0
  initialise = 1
  selected   = 1
  interrupt  = 0
that makes it xxx0 0110b == 0x0C
 

Penting !! Penawaran kerjasama bisnis.

2003-01-27 Thread Dessy

Dear Netter,

Terima kasih atas waktu yang anda luangkan untuk membaca e-mail ini, maaf
bila mengganggu waktu anda, dan apabila anda tidak berkenan silahkan di
delete saja.

Saya sedang mencari partner bisnis yang serius, yang mau meluangkan waktu 1
- 2 jam / harinya untuk mengembangkan bisnis ini, mudah-mudahan andalah
orang yang saya cari.

Bisnis yang saya kembangkan ini sangat mudah, dan tidak membutuhkan modal
besar.

Namun, jika anda memiliki kemauan keras untuk sukses, saya yakin anda akan
bisa mendapatkannya bersama bisnis ini dalam waktu relatif singkat ( +/- 12 bulan )

Silakan pelajari profile bisnis saya di :

http://adin.biz-page.com

Best regards dan mohon maaf bila mengganggu,

Adi Nugroho











___
Bug-hurd mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-hurd



$BL$>5Bz9-9p"(!Z#1#0#5L>MM(B$B$K%W%l%<%s%H![!!%m!<%:%R%C(B$B%WB>%@%$%(%C%H>&IJ$r(B $B$I(B$B$I!A$s$HAm@*(B105$BL>MM$K!*(B

2003-01-27 Thread Arelax . NET-AD
<$B;v6H $BM-8B2q http://www.rakuten.co.jp/vivian/
(B<$B;v6H [EMAIL PROTECTED] 
(B
(B<$BAw?. $B%"%j%i%C%/%9%"%/%;%9%"%C%W%5%]!<%HG[?.Be9T([EMAIL PROTECTED]
$B"(FCDj>&$7$J$$>l9g$NO"MmJ}K!(B>
$BEvJ}$+$i$N9-9pG[?.Dd;_$r4uK>$5$l$kJ}$O!"$3$N%a!<%k$K$=$N$^$^JV?.$$(B
$B$?$@$/$+!"$r!VG[?.Dd;_!W$H=q$-49$(JV?.$7$F$/$@$5$$!#(B
$B!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=(B
(B
(B
$B!y!y!z!!%@%$%(%C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