snp.c (130585) | snp.c (130640) |
---|---|
1/* 2 * Copyright (c) 1995 Ugen J.S.Antsilevich 3 * 4 * Redistribution and use in source forms, with and without modification, 5 * are permitted provided that this entire comment appears intact. 6 * 7 * Redistribution in binary form may occur without any restrictions. 8 * Obviously, it would be nice if you gave credit where credit is due 9 * but requiring it would be too onerous. 10 * 11 * This software is provided ``AS IS'' without any warranties of any kind. 12 * 13 * Snoop stuff. 14 * 15 */ 16 17#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1995 Ugen J.S.Antsilevich 3 * 4 * Redistribution and use in source forms, with and without modification, 5 * are permitted provided that this entire comment appears intact. 6 * 7 * Redistribution in binary form may occur without any restrictions. 8 * Obviously, it would be nice if you gave credit where credit is due 9 * but requiring it would be too onerous. 10 * 11 * This software is provided ``AS IS'' without any warranties of any kind. 12 * 13 * Snoop stuff. 14 * 15 */ 16 17#include <sys/cdefs.h> |
18__FBSDID("$FreeBSD: head/sys/dev/snp/snp.c 130585 2004-06-16 09:47:26Z phk $"); | 18__FBSDID("$FreeBSD: head/sys/dev/snp/snp.c 130640 2004-06-17 17:16:53Z phk $"); |
19 20#include <sys/param.h> 21#include <sys/systm.h> 22#include <sys/filio.h> 23#include <sys/malloc.h> 24#include <sys/tty.h> 25#include <sys/conf.h> 26#include <sys/poll.h> --- 374 unchanged lines hidden (view full) --- 401 snp->snp_blen = SNOOP_MINLEN; 402 snp->snp_base = 0; 403 snp->snp_len = 0; 404 405 /* 406 * snp_tty == NULL is for inactive snoop devices. 407 */ 408 snp->snp_tty = NULL; | 19 20#include <sys/param.h> 21#include <sys/systm.h> 22#include <sys/filio.h> 23#include <sys/malloc.h> 24#include <sys/tty.h> 25#include <sys/conf.h> 26#include <sys/poll.h> --- 374 unchanged lines hidden (view full) --- 401 snp->snp_blen = SNOOP_MINLEN; 402 snp->snp_base = 0; 403 snp->snp_len = 0; 404 405 /* 406 * snp_tty == NULL is for inactive snoop devices. 407 */ 408 snp->snp_tty = NULL; |
409 snp->snp_target = NODEV; | 409 snp->snp_target = NULL; |
410 411 LIST_INSERT_HEAD(&snp_sclist, snp, snp_list); 412 return (0); 413} 414 415 416static int 417snp_detach(snp) --- 16 unchanged lines hidden (view full) --- 434 tp->t_line == snooplinedisc) { 435 tp->t_sc = NULL; 436 tp->t_state &= ~TS_SNOOP; 437 tp->t_line = snp->snp_olddisc; 438 } else 439 printf("snp%d: bad attached tty data\n", snp->snp_unit); 440 441 snp->snp_tty = NULL; | 410 411 LIST_INSERT_HEAD(&snp_sclist, snp, snp_list); 412 return (0); 413} 414 415 416static int 417snp_detach(snp) --- 16 unchanged lines hidden (view full) --- 434 tp->t_line == snooplinedisc) { 435 tp->t_sc = NULL; 436 tp->t_state &= ~TS_SNOOP; 437 tp->t_line = snp->snp_olddisc; 438 } else 439 printf("snp%d: bad attached tty data\n", snp->snp_unit); 440 441 snp->snp_tty = NULL; |
442 snp->snp_target = NODEV; | 442 snp->snp_target = NULL; |
443 444detach_notty: 445 selwakeuppri(&snp->snp_sel, PZERO + 1); 446 if ((snp->snp_flags & SNOOP_OPEN) == 0) 447 free(snp, M_SNP); 448 449 return (0); 450} --- 44 unchanged lines hidden (view full) --- 495 struct snoop *snp; 496 struct tty *tp, *tpo; 497 struct cdev *tdev; 498 int s; 499 500 snp = dev->si_drv1; 501 switch (cmd) { 502 case SNPSTTY: | 443 444detach_notty: 445 selwakeuppri(&snp->snp_sel, PZERO + 1); 446 if ((snp->snp_flags & SNOOP_OPEN) == 0) 447 free(snp, M_SNP); 448 449 return (0); 450} --- 44 unchanged lines hidden (view full) --- 495 struct snoop *snp; 496 struct tty *tp, *tpo; 497 struct cdev *tdev; 498 int s; 499 500 snp = dev->si_drv1; 501 switch (cmd) { 502 case SNPSTTY: |
503 tdev = udev2dev(*((udev_t *)data)); 504 if (tdev == NODEV) | 503 tdev = findcdev(*((dev_t *)data)); 504 if (tdev == NULL) |
505 return (snp_down(snp)); 506 507 tp = snpdevtotty(tdev); 508 if (!tp) 509 return (EINVAL); 510 if (tp->t_state & TS_SNOOP) 511 return (EBUSY); 512 513 s = spltty(); 514 | 505 return (snp_down(snp)); 506 507 tp = snpdevtotty(tdev); 508 if (!tp) 509 return (EINVAL); 510 if (tp->t_state & TS_SNOOP) 511 return (EBUSY); 512 513 s = spltty(); 514 |
515 if (snp->snp_target == NODEV) { | 515 if (snp->snp_target == NULL) { |
516 tpo = snp->snp_tty; 517 if (tpo) 518 tpo->t_state &= ~TS_SNOOP; 519 } 520 521 tp->t_sc = (caddr_t)snp; 522 tp->t_state |= TS_SNOOP; 523 snp->snp_olddisc = tp->t_line; --- 11 unchanged lines hidden (view full) --- 535 break; 536 537 case SNPGTTY: 538 /* 539 * We keep snp_target field specially to make 540 * SNPGTTY happy, else we can't know what is device 541 * major/minor for tty. 542 */ | 516 tpo = snp->snp_tty; 517 if (tpo) 518 tpo->t_state &= ~TS_SNOOP; 519 } 520 521 tp->t_sc = (caddr_t)snp; 522 tp->t_state |= TS_SNOOP; 523 snp->snp_olddisc = tp->t_line; --- 11 unchanged lines hidden (view full) --- 535 break; 536 537 case SNPGTTY: 538 /* 539 * We keep snp_target field specially to make 540 * SNPGTTY happy, else we can't know what is device 541 * major/minor for tty. 542 */ |
543 *((udev_t *)data) = dev2udev(snp->snp_target); | 543 *((dev_t *)data) = dev2udev(snp->snp_target); |
544 break; 545 546 case FIONBIO: 547 break; 548 549 case FIOASYNC: 550 if (*(int *)data) 551 snp->snp_flags |= SNOOP_ASYNC; --- 52 unchanged lines hidden (view full) --- 604snp_clone(arg, name, namelen, dev) 605 void *arg; 606 char *name; 607 int namelen; 608 struct cdev **dev; 609{ 610 int u, i; 611 | 544 break; 545 546 case FIONBIO: 547 break; 548 549 case FIOASYNC: 550 if (*(int *)data) 551 snp->snp_flags |= SNOOP_ASYNC; --- 52 unchanged lines hidden (view full) --- 604snp_clone(arg, name, namelen, dev) 605 void *arg; 606 char *name; 607 int namelen; 608 struct cdev **dev; 609{ 610 int u, i; 611 |
612 if (*dev != NODEV) | 612 if (*dev != NULL) |
613 return; 614 if (dev_stdclone(name, NULL, "snp", &u) != 1) 615 return; 616 i = clone_create(&snpclones, &snp_cdevsw, &u, dev, 0); 617 if (i) 618 *dev = make_dev(&snp_cdevsw, unit2minor(u), 619 UID_ROOT, GID_WHEEL, 0600, "snp%d", u); 620 if (*dev != NULL) --- 37 unchanged lines hidden --- | 613 return; 614 if (dev_stdclone(name, NULL, "snp", &u) != 1) 615 return; 616 i = clone_create(&snpclones, &snp_cdevsw, &u, dev, 0); 617 if (i) 618 *dev = make_dev(&snp_cdevsw, unit2minor(u), 619 UID_ROOT, GID_WHEEL, 0600, "snp%d", u); 620 if (*dev != NULL) --- 37 unchanged lines hidden --- |