streams.c (49263) | streams.c (49344) |
---|---|
1/* 2 * Copyright (c) 1998 Mark Newton 3 * Copyright (c) 1994 Christos Zoulas 4 * Copyright (c) 1997 Todd Vierling 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 137 unchanged lines hidden (view full) --- 146 void *devfs_unix_ord_stream; 147#endif 148} ; 149 150#define UNIT(dev) minor(dev) /* assume one minor number per unit */ 151 152typedef struct streams_softc *sc_p; 153 | 1/* 2 * Copyright (c) 1998 Mark Newton 3 * Copyright (c) 1994 Christos Zoulas 4 * Copyright (c) 1997 Todd Vierling 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 137 unchanged lines hidden (view full) --- 146 void *devfs_unix_ord_stream; 147#endif 148} ; 149 150#define UNIT(dev) minor(dev) /* assume one minor number per unit */ 151 152typedef struct streams_softc *sc_p; 153 |
154static sc_p sca[NSTREAMS]; 155 | |
156static int 157streams_modevent(module_t mod, int type, void *unused) 158{ 159 switch (type) { 160 case MOD_LOAD: | 154static int 155streams_modevent(module_t mod, int type, void *unused) 156{ 157 switch (type) { 158 case MOD_LOAD: |
159 /* XXX should make sure it isn't already loaded first */ |
|
161 cdevsw_add(&streams_cdevsw); 162 return 0; 163 case MOD_UNLOAD: | 160 cdevsw_add(&streams_cdevsw); 161 return 0; 162 case MOD_UNLOAD: |
163 /* XXX should check to see if it's busy first */ 164 cdevsw_remove(&streams_cdevsw); |
|
164 return 0; 165 default: 166 break; 167 } 168 return 0; 169} 170 171static moduledata_t streams_mod = { --- 203 unchanged lines hidden (view full) --- 375 376 /* CHECKUNIT_DIAG(ENXIO);*/ 377 378 svr4_delete_socket(p, fp); 379 free(so->so_emuldata, M_TEMP); 380 return soo_close(fp, p); 381 return (0); 382} | 165 return 0; 166 default: 167 break; 168 } 169 return 0; 170} 171 172static moduledata_t streams_mod = { --- 203 unchanged lines hidden (view full) --- 376 377 /* CHECKUNIT_DIAG(ENXIO);*/ 378 379 svr4_delete_socket(p, fp); 380 free(so->so_emuldata, M_TEMP); 381 return soo_close(fp, p); 382 return (0); 383} |
383 384/* 385 * Now for some driver initialisation. 386 * Occurs ONCE during boot (very early). 387 */ 388static void 389streams_drvinit(void *unused) 390{ 391 int unit; 392 sc_p scp = sca[unit]; 393 394 for (unit = 0; unit < NSTREAMS; unit++) { 395 /* 396 * Allocate storage for this instance . 397 */ 398 scp = malloc(sizeof(*scp), M_DEVBUF, M_NOWAIT); 399 if( scp == NULL) { 400 printf("streams%d failed to allocate strorage\n", unit); 401 return ; 402 } 403 bzero(scp, sizeof(*scp)); 404 sca[unit] = scp; 405#if DEVFS 406 /* XXX - This stuff is all completely bogus -- It's supposed 407 * to show up in /compat/svr4/dev, but devfs will be mounted 408 * on /dev, won't it? Sigh. CHECKALTEXIST() will mean 409 * device opens will still work (and it will mitigate the 410 * need to run SVR4_MAKEDEV in /compat/svr4/dev, or will 411 * replace it with a script which creates symlinks to entities 412 * in /dev, or something equally 'orrible), but it's 413 * still a botch to put emulator-specific devices in the 414 * "global" part of the filesystem tree (especially scumsucking 415 * devices like these). Good thing hardly anyone uses 416 * devfs, right? 417 */ 418 scp->devfs_ptm = devfs_add_devswf(&streams_cdevsw, dev_ptm, DV_CHR, 419 UID_ROOT, GID_KMEM, 0640, "ptmx%d", unit); 420 scp->devfs_arp = devfs_add_devswf(&streams_cdevsw, dev_arp, DV_CHR, 421 UID_ROOT, GID_KMEM, 0666, "arp%d", unit); 422 scp->devfs_icmp = devfs_add_devswf(&streams_cdevsw, dev_icmp, DV_CHR, 423 UID_ROOT, GID_KMEM, 0600, "icmp%d", unit); 424 scp->devfs_ip = devfs_add_devswf(&streams_cdevsw, dev_ip, DV_CHR, 425 UID_ROOT, GID_KMEM, 0600, "ip%d", unit); 426 scp->devfs_tcp = devfs_add_devswf(&streams_cdevsw, dev_tcp, DV_CHR, 427 UID_ROOT, GID_KMEM, 0666, "tcp%d", unit); 428 scp->devfs_udp = devfs_add_devswf(&streams_cdevsw, dev_udp, DV_CHR, 429 UID_ROOT, GID_KMEM, 0666, "udp%d", unit); 430 scp->devfs_rawip = devfs_add_devswf(&streams_cdevsw, dev_rawip, DV_CHR, 431 UID_ROOT, GID_KMEM, 0600, "rawip%d", unit); 432 scp->devfs_unix_dgram = devfs_add_devswf(&streams_cdevsw, dev_unix_dgram, DV_CHR, 433 UID_ROOT, GID_KMEM, 0666, "ticlts%d", unit); 434 scp->devfs_unix_stream = devfs_add_devswf(&streams_cdevsw, dev_unix_stream, DV_CHR, 435 UID_ROOT, GID_KMEM, 0666, "ticots%d", unit); 436 scp->devfs_unix_ord_stream = devfs_add_devswf(&streams_cdevsw, dev_unix_ord_stream, DV_CHR, 437 UID_ROOT, GID_KMEM, 0666, "ticotsord%d", unit); 438#endif 439 } 440} 441 442SYSINIT(streamsdev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+CDEV_MAJOR, 443 streams_drvinit, NULL) 444 445 | |