[PARPORT] Programming challenge!


David Campbell (campbell@torque.net)
Mon, 19 Oct 1998 18:42:28 +0800


To all budding kernel hackers:

Attached is a code fragment from the ppa driver modified to use parport calls
rather than by direct IO. Direct IO limits the driver to PC style hardware,
whereas parport calls allows for the driver to be generic for all hardware
platforms. Your job is to adjust the C code such that the optimum assembler
code is generated. Ideally this involves the minimum memory fetches to
evaluate the parallel port address.

REWARD: Credit in the change logs.

HINT:
Change "(l & 0xf0)" to "l" since the ">> 4" trims the bottom 4 bits.
This makes a *BIG* difference

David Campbell

PS: You will require a 2.1.x kernel for parport.h and parport_pc.h

============ test.c ===============
/*
* compile with
* "cc -O2 -D__KERNEL__ -fomit-frame-pointer \
* -fno-strength-reduce -m486 -malign-loops=2 \
* -malign-jumps=2 -o test.o -c test.c"
* then examine the result using
* "objdump -d test.o"
* you may need to pipe the output through more.
*/
#include <linux/parport.h>
#include <linux/parport_pc.h>

#define w_ctr(p, d) parport_pc_write_control(p, d)
#define r_str(p) parport_pc_read_status(p)
ppa_nibble_in(struct parport *p, char *buffer, int len)
{
   unsigned char h, l;
   int i;

   for (i = len; i; i--) {
        w_ctr(p, 0x4);
        h = r_str(p);
        w_ctr(p, 0x6);
        l = r_str(p);
        *buffer++ = (h & 0xf0) | ((l & 0xf0) >> 4);
   }
   return 1; /* All went well - we hope! */
}
============ test.c ===============
=======================================================
campbell@torque.net

Current project list:
a) Maintain Linux ZIP drivers (documentation needed)
b) Create Linux chipset specific parport drivers
c) Start on ParSCSI drivers (75% complete)

Any assistance to clearing this list most welcome

-- To unsubscribe, send mail to: linux-parport-request@torque.net --
-- with the single word "unsubscribe" in the body of the message. --



This archive was generated by hypermail 2.0b3 on Wed 30 Dec 1998 - 10:18:37 EST