lkml.org 
[lkml]   [1998]   [Apr]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectpatch parport/bitops
This is a patch against 2.1.97.

I'd like to add a few EPP parport operations (that I need
in a device driver).

I'd also like to get the following functions in asm/bitops.h:

ffs (with the same semantics as in the libc, therefore slightly
different in spirit from ffz)
hweight32/hweight16/hweight8 these count the number
of bits set in an N-bit word. The reason why I believe this
should be in an arch specific directory is because
most archs (other than i386, sparc pre v9 popc enhanced)
have instructions to do this. The reason there are 3 funcs
to do this is because the generic implementation is slightly
costly and the cost is lower with less bits.

Any objections/comments?

Tom
diff -u -r -N linux-2.1.97-orig/Documentation/networking/baycom.txt linux/Documentation/networking/baycom.txt
--- linux-2.1.97-orig/Documentation/networking/baycom.txt Tue Aug 5 18:49:50 1997
+++ linux/Documentation/networking/baycom.txt Wed Apr 22 09:29:09 1998
@@ -1,9 +1,41 @@
- LINUX DRIVER FOR BAYCOM MODEMS
+ LINUX DRIVERS FOR BAYCOM MODEMS

Thomas M. Sailer, HB9JNX/AE4WA, <sailer@ife.ee.ethz.ch>

-This document describes the Linux Kernel Driver for simple Baycom style
-amateur radio modems. The driver supports the following modems:
+!!NEW!! (04/98) The drivers for the baycom modems have been split into
+separate drivers as they did not share any code, and the driver
+and device names have changed.
+
+This document describes the Linux Kernel Drivers for simple Baycom style
+amateur radio modems.
+
+The following drivers are available:
+
+baycom_ser_fdx:
+ This driver supports the SER12 modems either full or half duplex.
+ Its baud rate may be changed via the `baud' module parameter,
+ therefore it supports just about every bit bang modem on a
+ serial port. Its devices are called bcsf0 through bcsf3.
+ This is the recommended driver for SER12 type modems,
+ however if you have a broken UART clone that does not have working
+ delta status bits, you may try baycom_ser_hdx.
+
+baycom_ser_hdx:
+ This is an alternative driver for SER12 type modems.
+ It only supports half duplex, and only 1200 baud. Its devices
+ are called bcsh0 through bcsh3. Use this driver only if baycom_ser_fdx
+ does not work with your UART.
+
+baycom_par:
+ This driver supports the par96 and picpar modems.
+ Its devices are called bcp0 through bcp3.
+
+baycom_epp:
+ This driver supports the epp modem.
+ Its devices are called bce0 through bce3.
+ This driver is work-in-progress.
+
+The following modems are supported:

ser12: This is a very simple 1200 baud AFSK modem. The modem consists only
of a modulator/demodulator chip, usually a TI TCM3105. The computer
@@ -28,6 +60,13 @@
an additional power supply. Furthermore, it incorporates a carrier
detect circuitry.

+epp: This is a high speed modem adaptor that connects to an enhanced parallel port.
+ Its target audience is users working over a high speed hub (76.8kbit/s).
+
+eppfpga: This is a redesign of the epp adaptor.
+
+
+
All of the above modems only support half duplex communications. However,
the driver supports the KISS (see below) fullduplex command. It then simply
starts to send as soon as there's a packet to transmit and does not care
@@ -36,41 +75,41 @@
access protocol.


-The Interface of the driver
+The Interface of the drivers

-Unlike previous drivers, the driver is no longer a character device,
-but it is now a true kernel network interface. Installation is therefore
-simple. Once installed, four interfaces named bc[0-3] are available.
+Unlike previous drivers, these drivers are no longer character devices,
+but they are now true kernel network interfaces. Installation is therefore
+simple. Once installed, four interfaces named bc{sf,sh,p,e}[0-3] are available.
sethdlc from the ax25 utilities may be used to set driver states etc.
Users of userland AX.25 stacks may use the net2kiss utility (also available
-in the ax25 utilities package) to converts packets of a network interface
+in the ax25 utilities package) to convert packets of a network interface
to a KISS stream on a pseudo tty. There's also a patch available from
me for WAMPES which allows attaching a kernel network interface directly.


Configuring the driver

-Every time the driver is inserted into the kernel, it has to know which
+Every time a driver is inserted into the kernel, it has to know which
modems it should access at which ports. This can be done with the setbaycom
utility. If you are only using one modem, you can also configure the
driver from the insmod command line (or by means of an option line in
/etc/conf.modules).

Examples:
- insmod baycom modem=1 iobase=0x3f8 irq=4 options=1
- sethdlc -i bc0 -p type ser12 io 0x3f8 irq 4 options 1
+ insmod baycom_ser_fdx mode="ser12*" iobase=0x3f8 irq=4
+ sethdlc -i bcsf0 -p mode "ser12*" io 0x3f8 irq 4

Both lines configure the first port to drive a ser12 modem at the first
-serial port (COM1 under DOS). options=1 instructs the driver to use
+serial port (COM1 under DOS). The * in the mode parameter instructs the driver to use
the software DCD algorithm (see below).

- insmod baycom modem=2 iobase=0x378 irq=7 options=1
- sethdlc -i bc0 -p type par96 io 0x378 irq 7 options 1
+ insmod baycom_par mode="picpar" iobase=0x378
+ sethdlc -i bcp0 -p mode "picpar" io 0x378
+
+Both lines configure the first port to drive a picpar modem at the
+first parallel port (LPT1 under DOS). (Note: picpar implies
+hardware DCD, par96 implies software DCD).

-Both lines configure the first port to drive a par96 or par97 modem at the
-first parallel port (LPT1 under DOS). options=1 instructs the driver to use
-the software DCD algorithm (see below).
-
The channel access parameters can be set with sethdlc -a or kissparms.
Note that both utilities interpret the values slightly different.

@@ -100,18 +139,19 @@

Compatibility with the rest of the Linux kernel

-The serial driver, the line printer (lp) driver and the baycom driver compete
+The serial driver and the baycom serial drivers compete
for the same hardware resources. Of course only one driver can access a given
interface at a time. The serial driver grabs all interfaces it can find at
-startup time. Therefore the baycom driver subsequently won't be able to
+startup time. Therefore the baycom drivers subsequently won't be able to
access a serial port. You might therefore find it necessary to release
a port owned by the serial driver with 'setserial /dev/ttyS# uart none', where
-# is the number of the interface. The baycom driver does not reserve any
-port at startup, unless one is specified on the 'insmod' command line. Another
-method to solve the problem is to compile all three drivers as modules and
-leave it to kerneld to load the correct driver depending on the application.
-
+# is the number of the interface. The baycom drivers do not reserve any
+ports at startup, unless one is specified on the 'insmod' command line. Another
+method to solve the problem is to compile all drivers as modules and
+leave it to kmod to load the correct driver depending on the application.

+The parallel port drivers (baycom_par, baycom_epp) now use the parport subsystem
+to arbitrate the ports between different client drivers.

vy 73s de
Tom Sailer, sailer@ife.ee.ethz.ch
diff -u -r -N linux-2.1.97-orig/drivers/misc/parport_arc.c linux/drivers/misc/parport_arc.c
--- linux-2.1.97-orig/drivers/misc/parport_arc.c Wed Feb 25 07:33:03 1998
+++ linux/drivers/misc/parport_arc.c Wed Apr 22 09:29:09 1998
@@ -82,6 +82,11 @@
arc_release_resources,
arc_claim_resources,

+ NULL, /* epp_write_data */
+ NULL, /* epp_read_data */
+ NULL, /* epp_write_addr */
+ NULL, /* epp_read_addr */
+
NULL, /* epp_write_block */
NULL, /* epp_read_block */

diff -u -r -N linux-2.1.97-orig/drivers/misc/parport_ax.c linux/drivers/misc/parport_ax.c
--- linux-2.1.97-orig/drivers/misc/parport_ax.c Wed Feb 25 07:33:03 1998
+++ linux/drivers/misc/parport_ax.c Wed Apr 22 09:29:09 1998
@@ -39,7 +39,8 @@
#define DATA 0x00
#define STATUS 0x01
#define CONTROL 0x02
-#define EPPREG 0x04
+#define EPPADDR 0x03
+#define EPPDATA 0x04

#define CFIFO 0x400
#define DFIFO 0x400
@@ -57,13 +58,25 @@
void
parport_ax_write_epp(struct parport *p, unsigned char d)
{
- outb(d, p->base + EPPREG);
+ outb(d, p->base + EPPDATA);
}

unsigned char
parport_ax_read_epp(struct parport *p)
{
- return inb(p->base + EPPREG);
+ return inb(p->base + EPPDATA);
+}
+
+void
+parport_ax_write_epp_addr(struct parport *p, unsigned char d)
+{
+ outb(d, p->base + EPPADDR);
+}
+
+unsigned char
+parport_ax_read_epp_addr(struct parport *p)
+{
+ return inb(p->base + EPPADDR);
}

unsigned char
@@ -295,6 +308,11 @@
parport_ax_release_resources,
parport_ax_claim_resources,

+ parport_ax_write_epp,
+ parport_ax_read_epp,
+ parport_ax_write_epp_addr,
+ parport_ax_read_epp_addr,
+
parport_ax_epp_write_block,
parport_ax_epp_read_block,

@@ -490,7 +508,7 @@
if (!(p = parport_register_port(base, irq, dma, &parport_ax_ops)))
return 0;

- /* Safe away pointer to our EBus DMA */
+ /* Save away pointer to our EBus DMA */
p->private_data = (void *)dev->base_address[2];

p->modes = PARPORT_MODE_PCSPP | parport_PS2_supported(p);
diff -u -r -N linux-2.1.97-orig/drivers/misc/parport_pc.c linux/drivers/misc/parport_pc.c
--- linux-2.1.97-orig/drivers/misc/parport_pc.c Wed Apr 15 23:38:36 1998
+++ linux/drivers/misc/parport_pc.c Wed Apr 22 09:29:09 1998
@@ -19,8 +19,8 @@
*
* In addition, there are some optional registers:
*
- * base+3 EPP command
- * base+4 EPP
+ * base+3 EPP address
+ * base+4 EPP data
* base+0x400 ECP config A
* base+0x401 ECP config B
* base+0x402 ECP control
@@ -59,12 +59,22 @@

void parport_pc_write_epp(struct parport *p, unsigned char d)
{
- outb(d, p->base+EPPREG);
+ outb(d, p->base+EPPDATA);
}

unsigned char parport_pc_read_epp(struct parport *p)
{
- return inb(p->base+EPPREG);
+ return inb(p->base+EPPDATA);
+}
+
+void parport_pc_write_epp_addr(struct parport *p, unsigned char d)
+{
+ outb(d, p->base+EPPADDR);
+}
+
+unsigned char parport_pc_read_epp_addr(struct parport *p)
+{
+ return inb(p->base+EPPADDR);
}

unsigned char parport_pc_read_configb(struct parport *p)
@@ -187,7 +197,7 @@
{
size_t got = 0;
for (; got < length; got++) {
- *((char*)buf)++ = inb (p->base+EPPREG);
+ *((char*)buf)++ = inb (p->base+EPPDATA);
if (inb (p->base+STATUS) & 0x01)
break;
}
@@ -198,7 +208,7 @@
{
size_t written = 0;
for (; written < length; written++) {
- outb (*((char*)buf)++, p->base+EPPREG);
+ outb (*((char*)buf)++, p->base+EPPDATA);
if (inb (p->base+STATUS) & 0x01)
break;
}
@@ -258,6 +268,11 @@
parport_pc_release_resources,
parport_pc_claim_resources,

+ parport_pc_write_epp,
+ parport_pc_read_epp,
+ parport_pc_write_epp_addr,
+ parport_pc_read_epp_addr,
+
parport_pc_epp_write_block,
parport_pc_epp_read_block,

diff -u -r -N linux-2.1.97-orig/include/asm-alpha/bitops.h linux/include/asm-alpha/bitops.h
--- linux-2.1.97-orig/include/asm-alpha/bitops.h Mon Mar 30 10:21:40 1998
+++ linux/include/asm-alpha/bitops.h Wed Apr 22 09:29:09 1998
@@ -183,6 +183,70 @@
}

/*
+ * ffs: find first bit set. This is defined the same way as
+ * the libc and compiler builtin ffs routines, therefore
+ * differs in spirit from the above ffz (man ffs).
+ */
+
+extern __inline__ int ffs(int x)
+{
+ int r = 1;
+
+ if (!x)
+ return 0;
+ if (!(x & 0xffff)) {
+ x >>= 16;
+ r += 16;
+ }
+ if (!(x & 0xff)) {
+ x >>= 8;
+ r += 8;
+ }
+ if (!(x & 0xf)) {
+ x >>= 4;
+ r += 4;
+ }
+ if (!(x & 3)) {
+ x >>= 2;
+ r += 2;
+ }
+ if (!(x & 1)) {
+ x >>= 1;
+ r += 1;
+ }
+ return r;
+}
+
+/*
+ * hweightN: returns the hamming weight (i.e. the number
+ * of bits set) of a N-bit word
+ */
+
+extern __inline__ unsigned int hweight32(unsigned int w)
+{
+ unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
+ res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
+ res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
+ res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
+ return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
+}
+
+extern __inline__ unsigned int hweight16(unsigned int w)
+{
+ unsigned int res = (w & 0x5555) + ((w >> 1) & 0x5555);
+ res = (res & 0x3333) + ((res >> 2) & 0x3333);
+ res = (res & 0x0F0F) + ((res >> 4) & 0x0F0F);
+ return (res & 0x00FF) + ((res >> 8) & 0x00FF);
+}
+
+extern __inline__ unsigned int hweight8(unsigned int w)
+{
+ unsigned int res = (w & 0x55) + ((w >> 1) & 0x55);
+ res = (res & 0x33) + ((res >> 2) & 0x33);
+ return (res & 0x0F) + ((res >> 4) & 0x0F);
+}
+
+/*
* Find next zero bit in a bitmap reasonably efficiently..
*/
extern inline unsigned long find_next_zero_bit(void * addr, unsigned long size, unsigned long offset)
diff -u -r -N linux-2.1.97-orig/include/asm-arm/bitops.h linux/include/asm-arm/bitops.h
--- linux-2.1.97-orig/include/asm-arm/bitops.h Wed Jan 21 01:39:42 1998
+++ linux/include/asm-arm/bitops.h Wed Apr 22 09:29:09 1998
@@ -53,6 +53,70 @@
return k;
}

+/*
+ * ffs: find first bit set. This is defined the same way as
+ * the libc and compiler builtin ffs routines, therefore
+ * differs in spirit from the above ffz (man ffs).
+ */
+
+extern __inline__ int ffs(int x)
+{
+ int r = 1;
+
+ if (!x)
+ return 0;
+ if (!(x & 0xffff)) {
+ x >>= 16;
+ r += 16;
+ }
+ if (!(x & 0xff)) {
+ x >>= 8;
+ r += 8;
+ }
+ if (!(x & 0xf)) {
+ x >>= 4;
+ r += 4;
+ }
+ if (!(x & 3)) {
+ x >>= 2;
+ r += 2;
+ }
+ if (!(x & 1)) {
+ x >>= 1;
+ r += 1;
+ }
+ return r;
+}
+
+/*
+ * hweightN: returns the hamming weight (i.e. the number
+ * of bits set) of a N-bit word
+ */
+
+extern __inline__ unsigned int hweight32(unsigned int w)
+{
+ unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
+ res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
+ res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
+ res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
+ return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
+}
+
+extern __inline__ unsigned int hweight16(unsigned int w)
+{
+ unsigned int res = (w & 0x5555) + ((w >> 1) & 0x5555);
+ res = (res & 0x3333) + ((res >> 2) & 0x3333);
+ res = (res & 0x0F0F) + ((res >> 4) & 0x0F0F);
+ return (res & 0x00FF) + ((res >> 8) & 0x00FF);
+}
+
+extern __inline__ unsigned int hweight8(unsigned int w)
+{
+ unsigned int res = (w & 0x55) + ((w >> 1) & 0x55);
+ res = (res & 0x33) + ((res >> 2) & 0x33);
+ return (res & 0x0F) + ((res >> 4) & 0x0F);
+}
+
#ifdef __KERNEL__

#define ext2_set_bit test_and_set_bit
diff -u -r -N linux-2.1.97-orig/include/asm-generic/bitops.h linux/include/asm-generic/bitops.h
--- linux-2.1.97-orig/include/asm-generic/bitops.h Mon Aug 15 09:54:22 1994
+++ linux/include/asm-generic/bitops.h Wed Apr 22 09:29:09 1998
@@ -50,4 +50,69 @@
mask = 1 << (nr & 0x1f);
return ((mask & *addr) != 0);
}
+
+/*
+ * ffs: find first bit set. This is defined the same way as
+ * the libc and compiler builtin ffs routines, therefore
+ * differs in spirit from the above ffz (man ffs).
+ */
+
+extern __inline__ int ffs(int x)
+{
+ int r = 1;
+
+ if (!x)
+ return 0;
+ if (!(x & 0xffff)) {
+ x >>= 16;
+ r += 16;
+ }
+ if (!(x & 0xff)) {
+ x >>= 8;
+ r += 8;
+ }
+ if (!(x & 0xf)) {
+ x >>= 4;
+ r += 4;
+ }
+ if (!(x & 3)) {
+ x >>= 2;
+ r += 2;
+ }
+ if (!(x & 1)) {
+ x >>= 1;
+ r += 1;
+ }
+ return r;
+}
+
+/*
+ * hweightN: returns the hamming weight (i.e. the number
+ * of bits set) of a N-bit word
+ */
+
+extern __inline__ unsigned int hweight32(unsigned int w)
+{
+ unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
+ res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
+ res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
+ res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
+ return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
+}
+
+extern __inline__ unsigned int hweight16(unsigned int w)
+{
+ unsigned int res = (w & 0x5555) + ((w >> 1) & 0x5555);
+ res = (res & 0x3333) + ((res >> 2) & 0x3333);
+ res = (res & 0x0F0F) + ((res >> 4) & 0x0F0F);
+ return (res & 0x00FF) + ((res >> 8) & 0x00FF);
+}
+
+extern __inline__ unsigned int hweight8(unsigned int w)
+{
+ unsigned int res = (w & 0x55) + ((w >> 1) & 0x55);
+ res = (res & 0x33) + ((res >> 2) & 0x33);
+ return (res & 0x0F) + ((res >> 4) & 0x0F);
+}
+
#endif /* _ASM_GENERIC_BITOPS_H */
diff -u -r -N linux-2.1.97-orig/include/asm-i386/bitops.h linux/include/asm-i386/bitops.h
--- linux-2.1.97-orig/include/asm-i386/bitops.h Mon Dec 1 20:16:57 1997
+++ linux/include/asm-i386/bitops.h Wed Apr 22 09:29:09 1998
@@ -187,6 +187,54 @@
return word;
}

+/*
+ * ffs: find first bit set. This is defined the same way as
+ * the libc and compiler builtin ffs routines, therefore
+ * differs in spirit from the above ffz (man ffs).
+ */
+
+extern __inline__ int ffs(int x)
+{
+ int r;
+
+ __asm__("bsfl %1,%0\n\t"
+ "jnz 1f\n\t"
+ "movl $-1,%0\n"
+ "1:" : "=r" (r) : "g" (x));
+ return r+1;
+}
+
+/*
+ * hweightN: returns the hamming weight (i.e. the number
+ * of bits set) of a N-bit word
+ */
+
+extern __inline__ unsigned int hweight32(unsigned int w)
+{
+ unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
+ res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
+ res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
+ res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
+ return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
+}
+
+extern __inline__ unsigned int hweight16(unsigned int w)
+{
+ unsigned int res = (w & 0x5555) + ((w >> 1) & 0x5555);
+ res = (res & 0x3333) + ((res >> 2) & 0x3333);
+ res = (res & 0x0F0F) + ((res >> 4) & 0x0F0F);
+ return (res & 0x00FF) + ((res >> 8) & 0x00FF);
+}
+
+extern __inline__ unsigned int hweight8(unsigned int w)
+{
+ unsigned int res = (w & 0x55) + ((w >> 1) & 0x55);
+ res = (res & 0x33) + ((res >> 2) & 0x33);
+ return (res & 0x0F) + ((res >> 4) & 0x0F);
+}
+
+
+
#ifdef __KERNEL__

#define ext2_set_bit test_and_set_bit
diff -u -r -N linux-2.1.97-orig/include/asm-i386/unistd.h linux/include/asm-i386/unistd.h
--- linux-2.1.97-orig/include/asm-i386/unistd.h Tue Apr 7 17:05:05 1998
+++ linux/include/asm-i386/unistd.h Wed Apr 22 09:29:09 1998
@@ -296,6 +296,7 @@
static inline _syscall1(int,_exit,int,exitcode)
static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
static inline _syscall1(int,delete_module,const char *,name)
+static inline _syscall2(int,fstat,unsigned int,fd,struct stat *,statbuf)

static inline pid_t wait(int * wait_stat)
{
diff -u -r -N linux-2.1.97-orig/include/asm-m68k/bitops.h linux/include/asm-m68k/bitops.h
--- linux-2.1.97-orig/include/asm-m68k/bitops.h Fri Feb 13 01:30:13 1998
+++ linux/include/asm-m68k/bitops.h Wed Apr 22 09:29:09 1998
@@ -210,6 +210,70 @@
return res ^ 31;
}

+/*
+ * ffs: find first bit set. This is defined the same way as
+ * the libc and compiler builtin ffs routines, therefore
+ * differs in spirit from the above ffz (man ffs).
+ */
+
+extern __inline__ int ffs(int x)
+{
+ int r = 1;
+
+ if (!x)
+ return 0;
+ if (!(x & 0xffff)) {
+ x >>= 16;
+ r += 16;
+ }
+ if (!(x & 0xff)) {
+ x >>= 8;
+ r += 8;
+ }
+ if (!(x & 0xf)) {
+ x >>= 4;
+ r += 4;
+ }
+ if (!(x & 3)) {
+ x >>= 2;
+ r += 2;
+ }
+ if (!(x & 1)) {
+ x >>= 1;
+ r += 1;
+ }
+ return r;
+}
+
+/*
+ * hweightN: returns the hamming weight (i.e. the number
+ * of bits set) of a N-bit word
+ */
+
+extern __inline__ unsigned int hweight32(unsigned int w)
+{
+ unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
+ res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
+ res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
+ res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
+ return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
+}
+
+extern __inline__ unsigned int hweight16(unsigned int w)
+{
+ unsigned int res = (w & 0x5555) + ((w >> 1) & 0x5555);
+ res = (res & 0x3333) + ((res >> 2) & 0x3333);
+ res = (res & 0x0F0F) + ((res >> 4) & 0x0F0F);
+ return (res & 0x00FF) + ((res >> 8) & 0x00FF);
+}
+
+extern __inline__ unsigned int hweight8(unsigned int w)
+{
+ unsigned int res = (w & 0x55) + ((w >> 1) & 0x55);
+ res = (res & 0x33) + ((res >> 2) & 0x33);
+ return (res & 0x0F) + ((res >> 4) & 0x0F);
+}
+
/* Bitmap functions for the minix filesystem */

extern __inline__ int
diff -u -r -N linux-2.1.97-orig/include/asm-mips/bitops.h linux/include/asm-mips/bitops.h
--- linux-2.1.97-orig/include/asm-mips/bitops.h Tue Dec 16 21:45:55 1997
+++ linux/include/asm-mips/bitops.h Wed Apr 22 09:29:09 1998
@@ -372,6 +372,70 @@
return __res;
}

+/*
+ * ffs: find first bit set. This is defined the same way as
+ * the libc and compiler builtin ffs routines, therefore
+ * differs in spirit from the above ffz (man ffs).
+ */
+
+extern __inline__ int ffs(int x)
+{
+ int r = 1;
+
+ if (!x)
+ return 0;
+ if (!(x & 0xffff)) {
+ x >>= 16;
+ r += 16;
+ }
+ if (!(x & 0xff)) {
+ x >>= 8;
+ r += 8;
+ }
+ if (!(x & 0xf)) {
+ x >>= 4;
+ r += 4;
+ }
+ if (!(x & 3)) {
+ x >>= 2;
+ r += 2;
+ }
+ if (!(x & 1)) {
+ x >>= 1;
+ r += 1;
+ }
+ return r;
+}
+
+/*
+ * hweightN: returns the hamming weight (i.e. the number
+ * of bits set) of a N-bit word
+ */
+
+extern __inline__ unsigned int hweight32(unsigned int w)
+{
+ unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
+ res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
+ res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
+ res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
+ return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
+}
+
+extern __inline__ unsigned int hweight16(unsigned int w)
+{
+ unsigned int res = (w & 0x5555) + ((w >> 1) & 0x5555);
+ res = (res & 0x3333) + ((res >> 2) & 0x3333);
+ res = (res & 0x0F0F) + ((res >> 4) & 0x0F0F);
+ return (res & 0x00FF) + ((res >> 8) & 0x00FF);
+}
+
+extern __inline__ unsigned int hweight8(unsigned int w)
+{
+ unsigned int res = (w & 0x55) + ((w >> 1) & 0x55);
+ res = (res & 0x33) + ((res >> 2) & 0x33);
+ return (res & 0x0F) + ((res >> 4) & 0x0F);
+}
+
#ifdef __MIPSEB__
/* For now I steal the Sparc C versions, no need for speed, just need to
* get it working.
diff -u -r -N linux-2.1.97-orig/include/asm-ppc/bitops.h linux/include/asm-ppc/bitops.h
--- linux-2.1.97-orig/include/asm-ppc/bitops.h Sat Aug 16 18:51:09 1997
+++ linux/include/asm-ppc/bitops.h Wed Apr 22 09:29:09 1998
@@ -97,6 +97,70 @@
}

/*
+ * ffs: find first bit set. This is defined the same way as
+ * the libc and compiler builtin ffs routines, therefore
+ * differs in spirit from the above ffz (man ffs).
+ */
+
+extern __inline__ int ffs(int x)
+{
+ int r = 1;
+
+ if (!x)
+ return 0;
+ if (!(x & 0xffff)) {
+ x >>= 16;
+ r += 16;
+ }
+ if (!(x & 0xff)) {
+ x >>= 8;
+ r += 8;
+ }
+ if (!(x & 0xf)) {
+ x >>= 4;
+ r += 4;
+ }
+ if (!(x & 3)) {
+ x >>= 2;
+ r += 2;
+ }
+ if (!(x & 1)) {
+ x >>= 1;
+ r += 1;
+ }
+ return r;
+}
+
+/*
+ * hweightN: returns the hamming weight (i.e. the number
+ * of bits set) of a N-bit word
+ */
+
+extern __inline__ unsigned int hweight32(unsigned int w)
+{
+ unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
+ res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
+ res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
+ res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
+ return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
+}
+
+extern __inline__ unsigned int hweight16(unsigned int w)
+{
+ unsigned int res = (w & 0x5555) + ((w >> 1) & 0x5555);
+ res = (res & 0x3333) + ((res >> 2) & 0x3333);
+ res = (res & 0x0F0F) + ((res >> 4) & 0x0F0F);
+ return (res & 0x00FF) + ((res >> 8) & 0x00FF);
+}
+
+extern __inline__ unsigned int hweight8(unsigned int w)
+{
+ unsigned int res = (w & 0x55) + ((w >> 1) & 0x55);
+ res = (res & 0x33) + ((res >> 2) & 0x33);
+ return (res & 0x0F) + ((res >> 4) & 0x0F);
+}
+
+/*
* This implementation of find_{first,next}_zero_bit was stolen from
* Linus' asm-alpha/bitops.h.
*/
diff -u -r -N linux-2.1.97-orig/include/asm-sparc/bitops.h linux/include/asm-sparc/bitops.h
--- linux-2.1.97-orig/include/asm-sparc/bitops.h Wed Apr 15 02:44:23 1998
+++ linux/include/asm-sparc/bitops.h Wed Apr 22 09:29:09 1998
@@ -182,6 +182,70 @@
return result;
}

+/*
+ * ffs: find first bit set. This is defined the same way as
+ * the libc and compiler builtin ffs routines, therefore
+ * differs in spirit from the above ffz (man ffs).
+ */
+
+extern __inline__ int ffs(int x)
+{
+ int r = 1;
+
+ if (!x)
+ return 0;
+ if (!(x & 0xffff)) {
+ x >>= 16;
+ r += 16;
+ }
+ if (!(x & 0xff)) {
+ x >>= 8;
+ r += 8;
+ }
+ if (!(x & 0xf)) {
+ x >>= 4;
+ r += 4;
+ }
+ if (!(x & 3)) {
+ x >>= 2;
+ r += 2;
+ }
+ if (!(x & 1)) {
+ x >>= 1;
+ r += 1;
+ }
+ return r;
+}
+
+/*
+ * hweightN: returns the hamming weight (i.e. the number
+ * of bits set) of a N-bit word
+ */
+
+extern __inline__ unsigned int hweight32(unsigned int w)
+{
+ unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
+ res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
+ res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
+ res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
+ return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
+}
+
+extern __inline__ unsigned int hweight16(unsigned int w)
+{
+ unsigned int res = (w & 0x5555) + ((w >> 1) & 0x5555);
+ res = (res & 0x3333) + ((res >> 2) & 0x3333);
+ res = (res & 0x0F0F) + ((res >> 4) & 0x0F0F);
+ return (res & 0x00FF) + ((res >> 8) & 0x00FF);
+}
+
+extern __inline__ unsigned int hweight8(unsigned int w)
+{
+ unsigned int res = (w & 0x55) + ((w >> 1) & 0x55);
+ res = (res & 0x33) + ((res >> 2) & 0x33);
+ return (res & 0x0F) + ((res >> 4) & 0x0F);
+}
+
/* find_next_zero_bit() finds the first zero bit in a bit string of length
* 'size' bits, starting the search at bit 'offset'. This is largely based
* on Linus's ALPHA routines, which are pretty portable BTW.
diff -u -r -N linux-2.1.97-orig/include/asm-sparc64/bitops.h linux/include/asm-sparc64/bitops.h
--- linux-2.1.97-orig/include/asm-sparc64/bitops.h Tue Jan 13 00:15:54 1998
+++ linux/include/asm-sparc64/bitops.h Wed Apr 22 09:29:09 1998
@@ -186,6 +186,91 @@
return result;
}

+/*
+ * ffs: find first bit set. This is defined the same way as
+ * the libc and compiler builtin ffs routines, therefore
+ * differs in spirit from the above ffz (man ffs).
+ */
+
+extern __inline__ int ffs(int x)
+{
+ int r = 1;
+
+ if (!x)
+ return 0;
+ if (!(x & 0xffff)) {
+ x >>= 16;
+ r += 16;
+ }
+ if (!(x & 0xff)) {
+ x >>= 8;
+ r += 8;
+ }
+ if (!(x & 0xf)) {
+ x >>= 4;
+ r += 4;
+ }
+ if (!(x & 3)) {
+ x >>= 2;
+ r += 2;
+ }
+ if (!(x & 1)) {
+ x >>= 1;
+ r += 1;
+ }
+ return r;
+}
+
+/*
+ * hweightN: returns the hamming weight (i.e. the number
+ * of bits set) of a N-bit word
+ */
+
+extern __inline__ unsigned int hweight32(unsigned int w)
+{
+#ifdef ULTRA_HAS_POPULATION_COUNT
+ unsigned int res;
+
+ __asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xffffffff));
+ return res;
+#else
+ unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
+ res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
+ res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
+ res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
+ return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
+#endif
+}
+
+extern __inline__ unsigned int hweight16(unsigned int w)
+{
+#ifdef ULTRA_HAS_POPULATION_COUNT
+ unsigned int res;
+
+ __asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xffff));
+ return res;
+#else
+ unsigned int res = (w & 0x5555) + ((w >> 1) & 0x5555);
+ res = (res & 0x3333) + ((res >> 2) & 0x3333);
+ res = (res & 0x0F0F) + ((res >> 4) & 0x0F0F);
+ return (res & 0x00FF) + ((res >> 8) & 0x00FF);
+#endif
+}
+
+extern __inline__ unsigned int hweight8(unsigned int w)
+{
+#ifdef ULTRA_HAS_POPULATION_COUNT
+ unsigned int res;
+
+ __asm__ ("popc %1,%0" : "=r" (res) : "r" (w & 0xff));
+ return res;
+#else
+ unsigned int res = (w & 0x55) + ((w >> 1) & 0x55);
+ res = (res & 0x33) + ((res >> 2) & 0x33);
+ return (res & 0x0F) + ((res >> 4) & 0x0F);
+#endif
+}
+
/* find_next_zero_bit() finds the first zero bit in a bit string of length
* 'size' bits, starting the search at bit 'offset'. This is largely based
* on Linus's ALPHA routines, which are pretty portable BTW.
diff -u -r -N linux-2.1.97-orig/include/linux/parport.h linux/include/linux/parport.h
--- linux-2.1.97-orig/include/linux/parport.h Wed Apr 15 23:38:36 1998
+++ linux/include/linux/parport.h Thu Apr 23 10:05:30 1998
@@ -106,6 +106,10 @@
void (*release_resources)(struct parport *);
int (*claim_resources)(struct parport *);

+ void (*epp_write_data)(struct parport *, unsigned char);
+ unsigned char (*epp_read_data)(struct parport *);
+ void (*epp_write_addr)(struct parport *, unsigned char);
+ unsigned char (*epp_read_addr)(struct parport *);
size_t (*epp_write_block)(struct parport *, void *, size_t);
size_t (*epp_read_block)(struct parport *, void *, size_t);

@@ -330,6 +334,10 @@
#define parport_change_mode(p,m) parport_pc_change_mode(p,m)
#define parport_release_resources(p) parport_pc_release_resources(p)
#define parport_claim_resources(p) parport_pc_claim_resources(p)
+#define parport_epp_write_data(p,x) parport_pc_write_epp(p,x)
+#define parport_epp_read_data(p) parport_pc_read_epp(p)
+#define parport_epp_write_addr(p,x) parport_pc_write_epp_addr(p,x)
+#define parport_epp_read_addr(p) parport_pc_read_epp_addr(p)
#endif

#ifdef PARPORT_NEED_GENERIC_OPS
@@ -349,6 +357,10 @@
#define parport_change_mode(p,m) (p)->ops->change_mode(p,m)
#define parport_release_resources(p) (p)->ops->release_resources(p)
#define parport_claim_resources(p) (p)->ops->claim_resources(p)
+#define parport_epp_write_data(p,x) (p)->ops->epp_write_data(p,x)
+#define parport_epp_read_data(p) (p)->ops->epp_read_data(p)
+#define parport_epp_write_addr(p,x) (p)->ops->epp_write_addr(p,x)
+#define parport_epp_read_addr(p) (p)->ops->epp_read_addr(p)
#endif

#endif /* __KERNEL__ */
diff -u -r -N linux-2.1.97-orig/include/linux/parport_pc.h linux/include/linux/parport_pc.h
--- linux-2.1.97-orig/include/linux/parport_pc.h Wed Feb 25 07:33:04 1998
+++ linux/include/linux/parport_pc.h Wed Apr 22 10:10:26 1998
@@ -8,19 +8,30 @@
#define ECONTROL 0x402
#define CONFIGB 0x401
#define CONFIGA 0x400
-#define EPPREG 0x4
+#define EPPDATA 0x4
+#define EPPADDR 0x3
#define CONTROL 0x2
#define STATUS 0x1
#define DATA 0

extern __inline__ void parport_pc_write_epp(struct parport *p, unsigned char d)
{
- outb(d, p->base+EPPREG);
+ outb(d, p->base+EPPDATA);
}

extern __inline__ unsigned char parport_pc_read_epp(struct parport *p)
{
- return inb(p->base+EPPREG);
+ return inb(p->base+EPPDATA);
+}
+
+extern __inline__ void parport_pc_write_epp_addr(struct parport *p, unsigned char d)
+{
+ outb(d, p->base+EPPADDR);
+}
+
+extern __inline__ unsigned char parport_pc_read_epp_addr(struct parport *p)
+{
+ return inb(p->base+EPPADDR);
}

extern __inline__ unsigned char parport_pc_read_configb(struct parport *p)
\
 
 \ /
  Last update: 2005-03-22 13:42    [W:0.183 / U:5.056 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site