ppi.c (ca3d37955c7c41e64a80c97b3f1c1fa4e9ff4897) ppi.c (6bfa9a2d66dd0e00182017d6741d44e54d0b2cca)
1/*-
2 * Copyright (c) 1997, 1998, 1999 Nicolas Souchu, Michael Smith
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 238 unchanged lines hidden (view full) ---

247
248 return;
249}
250#endif /* PERIPH_1284 */
251
252static int
253ppiopen(struct cdev *dev, int flags, int fmt, struct thread *td)
254{
1/*-
2 * Copyright (c) 1997, 1998, 1999 Nicolas Souchu, Michael Smith
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 238 unchanged lines hidden (view full) ---

247
248 return;
249}
250#endif /* PERIPH_1284 */
251
252static int
253ppiopen(struct cdev *dev, int flags, int fmt, struct thread *td)
254{
255 u_int unit = minor(dev);
255 u_int unit = dev2unit(dev);
256 struct ppi_data *ppi = UNITOSOFTC(unit);
257 device_t ppidev = UNITODEVICE(unit);
258 device_t ppbus = device_get_parent(ppidev);
259 int res;
260
261 if (!ppi)
262 return (ENXIO);
263

--- 17 unchanged lines hidden (view full) ---

281 ppi->ppi_count += 1;
282
283 return (0);
284}
285
286static int
287ppiclose(struct cdev *dev, int flags, int fmt, struct thread *td)
288{
256 struct ppi_data *ppi = UNITOSOFTC(unit);
257 device_t ppidev = UNITODEVICE(unit);
258 device_t ppbus = device_get_parent(ppidev);
259 int res;
260
261 if (!ppi)
262 return (ENXIO);
263

--- 17 unchanged lines hidden (view full) ---

281 ppi->ppi_count += 1;
282
283 return (0);
284}
285
286static int
287ppiclose(struct cdev *dev, int flags, int fmt, struct thread *td)
288{
289 u_int unit = minor(dev);
289 u_int unit = dev2unit(dev);
290 struct ppi_data *ppi = UNITOSOFTC(unit);
291 device_t ppidev = UNITODEVICE(unit);
292 device_t ppbus = device_get_parent(ppidev);
293
294 ppi->ppi_count --;
295 if (!ppi->ppi_count) {
296
297#ifdef PERIPH_1284

--- 26 unchanged lines hidden (view full) ---

324 *
325 * First, try negotiation to BYTE then NIBBLE mode
326 * If no data is available, wait for it otherwise transfer as much as possible
327 */
328static int
329ppiread(struct cdev *dev, struct uio *uio, int ioflag)
330{
331#ifdef PERIPH_1284
290 struct ppi_data *ppi = UNITOSOFTC(unit);
291 device_t ppidev = UNITODEVICE(unit);
292 device_t ppbus = device_get_parent(ppidev);
293
294 ppi->ppi_count --;
295 if (!ppi->ppi_count) {
296
297#ifdef PERIPH_1284

--- 26 unchanged lines hidden (view full) ---

324 *
325 * First, try negotiation to BYTE then NIBBLE mode
326 * If no data is available, wait for it otherwise transfer as much as possible
327 */
328static int
329ppiread(struct cdev *dev, struct uio *uio, int ioflag)
330{
331#ifdef PERIPH_1284
332 u_int unit = minor(dev);
332 u_int unit = dev2unit(dev);
333 struct ppi_data *ppi = UNITOSOFTC(unit);
334 device_t ppidev = UNITODEVICE(unit);
335 device_t ppbus = device_get_parent(ppidev);
336 int len, error = 0;
337
338 switch (ppb_1284_get_state(ppbus)) {
339 case PPB_PERIPHERAL_IDLE:
340 ppb_peripheral_terminate(ppbus, 0);

--- 67 unchanged lines hidden (view full) ---

408 * process
409 *
410 * Once negotiation done, transfer data
411 */
412static int
413ppiwrite(struct cdev *dev, struct uio *uio, int ioflag)
414{
415#ifdef PERIPH_1284
333 struct ppi_data *ppi = UNITOSOFTC(unit);
334 device_t ppidev = UNITODEVICE(unit);
335 device_t ppbus = device_get_parent(ppidev);
336 int len, error = 0;
337
338 switch (ppb_1284_get_state(ppbus)) {
339 case PPB_PERIPHERAL_IDLE:
340 ppb_peripheral_terminate(ppbus, 0);

--- 67 unchanged lines hidden (view full) ---

408 * process
409 *
410 * Once negotiation done, transfer data
411 */
412static int
413ppiwrite(struct cdev *dev, struct uio *uio, int ioflag)
414{
415#ifdef PERIPH_1284
416 u_int unit = minor(dev);
416 u_int unit = dev2unit(dev);
417 struct ppi_data *ppi = UNITOSOFTC(unit);
418 device_t ppidev = UNITODEVICE(unit);
419 device_t ppbus = device_get_parent(ppidev);
420 int len, error = 0, sent;
421
422#if 0
423 int ret;
424

--- 69 unchanged lines hidden (view full) ---

494#endif
495
496 return (error);
497}
498
499static int
500ppiioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td)
501{
417 struct ppi_data *ppi = UNITOSOFTC(unit);
418 device_t ppidev = UNITODEVICE(unit);
419 device_t ppbus = device_get_parent(ppidev);
420 int len, error = 0, sent;
421
422#if 0
423 int ret;
424

--- 69 unchanged lines hidden (view full) ---

494#endif
495
496 return (error);
497}
498
499static int
500ppiioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td)
501{
502 u_int unit = minor(dev);
502 u_int unit = dev2unit(dev);
503 device_t ppidev = UNITODEVICE(unit);
504 device_t ppbus = device_get_parent(ppidev);
505 int error = 0;
506 u_int8_t *val = (u_int8_t *)data;
507
508 switch (cmd) {
509
510 case PPIGDATA: /* get data register */

--- 65 unchanged lines hidden ---
503 device_t ppidev = UNITODEVICE(unit);
504 device_t ppbus = device_get_parent(ppidev);
505 int error = 0;
506 u_int8_t *val = (u_int8_t *)data;
507
508 switch (cmd) {
509
510 case PPIGDATA: /* get data register */

--- 65 unchanged lines hidden ---