/*ARGSUSED*/ static int parseopen( queue_t *q, dev_t dev, int flag, int sflag ) { register parsestream_t *parse; static int notice = 0; parseprintf(DD_OPEN,("parse: OPEN\n")); if (sflag != MODOPEN) { /* open only for modules */ parseprintf(DD_OPEN,("parse: OPEN - FAILED - not MODOPEN\n")); return OPENFAIL; } if (q->q_ptr != (caddr_t)NULL) { u.u_error = EBUSY; parseprintf(DD_OPEN,("parse: OPEN - FAILED - EXCLUSIVE ONLY\n")); return OPENFAIL; } #ifdef VDDRV parsebusy++; #endif q->q_ptr = (caddr_t)kmem_alloc(sizeof(parsestream_t)); if (q->q_ptr == (caddr_t)0) { parseprintf(DD_OPEN,("parse: OPEN - FAILED - no memory\n")); #ifdef VDDRV parsebusy--; #endif return OPENFAIL; } WR(q)->q_ptr = q->q_ptr; parse = (parsestream_t *)(void *)q->q_ptr; bzero((caddr_t)parse, sizeof(*parse)); parse->parse_queue = q; parse->parse_status = PARSE_ENABLE; parse->parse_ppsclockev.tv.tv_sec = 0; parse->parse_ppsclockev.tv.tv_usec = 0; parse->parse_ppsclockev.serial = 0; if (!parse_ioinit(&parse->parse_io)) { /* * ok guys - beat it */ kmem_free((caddr_t)parse, sizeof(parsestream_t)); #ifdef VDDRV parsebusy--; #endif return OPENFAIL; } if (setup_stream(q, M_PARSE)) { (void) init_linemon(q); /* hook up PPS ISR routines if possible */ parseprintf(DD_OPEN,("parse: OPEN - SUCCEEDED\n")); /* * I know that you know the delete key, but you didn't write this * code, did you ? - So, keep the message in here. */ if (!notice) { #ifdef VDDRV printf("%s: Copyright (C) 1991-2005, Frank Kardel\n", parsesync_vd.Drv_name); #else printf("%s: Copyright (C) 1991-2005, Frank Kardel\n", "parsestreams.c,v 4.11 2005/04/16 17:32:10 kardel RELEASE_20050508_A"); #endif notice = 1; } return MODOPEN; } else { kmem_free((caddr_t)parse, sizeof(parsestream_t)); #ifdef VDDRV parsebusy--; #endif return OPENFAIL; } }
/*ARGSUSED*/ static int parseopen( queue_t *q, dev_t *dev, int flag, int sflag, cred_t *credp ) { register parsestream_t *parse; static int notice = 0; pprintf(DD_OPEN, "parse: OPEN - q=%x\n", q); if (sflag != MODOPEN) { /* open only for modules */ pprintf(DD_OPEN, "parse: OPEN - FAILED - not MODOPEN\n"); return EIO; } if (q->q_ptr != (caddr_t)NULL) { pprintf(DD_OPEN, "parse: OPEN - FAILED - EXCLUSIVE ONLY\n"); return EBUSY; } q->q_ptr = (caddr_t)kmem_alloc(sizeof(parsestream_t), KM_SLEEP); if (q->q_ptr == (caddr_t)0) { return ENOMEM; } pprintf(DD_OPEN, "parse: OPEN - parse area q=%x, q->q_ptr=%x\n", q, q->q_ptr); WR(q)->q_ptr = q->q_ptr; pprintf(DD_OPEN, "parse: OPEN - WQ parse area q=%x, q->q_ptr=%x\n", WR(q), WR(q)->q_ptr); parse = (parsestream_t *) q->q_ptr; bzero((caddr_t)parse, sizeof(*parse)); parse->parse_queue = q; parse->parse_status = PARSE_ENABLE; parse->parse_ppsclockev.tv.tv_sec = 0; parse->parse_ppsclockev.tv.tv_usec = 0; parse->parse_ppsclockev.serial = 0; qprocson(q); pprintf(DD_OPEN, "parse: OPEN - initializing io subsystem q=%x\n", q); if (!parse_ioinit(&parse->parse_io)) { /* * ok guys - beat it */ qprocsoff(q); kmem_free((caddr_t)parse, sizeof(parsestream_t)); return EIO; } pprintf(DD_OPEN, "parse: OPEN - initializing stream q=%x\n", q); if (setup_stream(q, M_PARSE)) { (void) init_linemon(q); /* hook up PPS ISR routines if possible */ pprintf(DD_OPEN, "parse: OPEN - SUCCEEDED\n"); /* * I know that you know the delete key, but you didn't write this * code, did you ? - So, keep the message in here. */ if (!notice) { cmn_err(CE_CONT, "?%s: Copyright (c) 1993-2005, Frank Kardel\n", modlstrmod.strmod_linkinfo); notice = 1; } return 0; } else { qprocsoff(q); kmem_free((caddr_t)parse, sizeof(parsestream_t)); return EIO; } }