⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 psostty.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/lib/psostty.c,v 1.3 2003/01/15 14:04:34 josh Exp $ *//* * Copyright (C) 1999-2005 Wind River Systems, Inc. * All rights reserved.  Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. *//**************************************************************************** *  Copyright 1998 Integrated Systems, Inc. *  All rights reserved. ****************************************************************************//* * $Log: psostty.c,v $ * Revision 1.3  2003/01/15 14:04:34  josh * directory structure shifting * * Revision 1.2  2001/11/08 15:56:25  tneale * Updated for newest file layout * * Revision 1.1.1.1  2001/11/05 17:48:42  tneale * Tornado shuffle * * Revision 2.14  2001/01/19 22:23:50  paul * Update copyright. * * Revision 2.13  2000/03/17 00:12:43  meister * Update copyright message * * Revision 2.12  1999/04/15 21:38:25  wes * Use symbolic values for flag bits * * Revision 2.11  1999/04/13 20:40:30  wes * Support psossim console * * Revision 2.10  1999/04/09 20:55:22  wes * fix a bunch of gcc warnings. * include new psosinit.h  (also included by root.c) for prototypes * of functions exported by this file. * * Revision 2.9  1998/12/15 05:47:18  sra * Get pSOS/X86 serial console working. * * Revision 2.8  1998/12/12 18:53:39  sra * Changes to pSOS port of Attache: support non-Ethernet NI drivers, * simplify packet buffer implementation, general cleanup. * * Revision 2.7  1998/09/22 19:46:25  wes * Use VMIN=1 instead of VMIN=0 (to work around apparent driver bug) * Do blocking read of serial console just like PC keyboard console. * Simplify extensively. * * Revision 2.6  1998/08/13 22:56:20  meister * conditionalize PC console include file * * Revision 2.5  1998/08/05 23:11:14  meister * added code to turn off echo on the PC console device * * Revision 2.4  1998/08/04 22:54:15  meister * Changed PEV_QEVENT, MSG_KBDCHAR, etc to have more attache-specific names * * Revision 2.3  1998/07/31 21:37:50  meister * Merge x86 pc console rotines back in * * Revision 2.2  1998/07/30 22:16:21  meister * get rid of printf, use BUG * * Revision 2.1  1998/07/24 21:04:01  meister * Added psostty.c * moved nidrive.c to attache/psos * * Revision 1.7  1998/07/24 17:03:15  meister * moved att_cfg.c, niatt.c, nimux.c to attache/psos * moved kbd_read_task to psostty.c * * Revision 1.6  1998/07/20 21:24:26  sra * Cleanup. * * Revision 1.5  1998/07/17 21:47:58  meister * minor code shufflage * * Revision 1.4  1998/07/17 06:37:24  sra * Add some casts to make CAD-UL happy. * * Revision 1.3  1998/06/24 18:46:48  meister * More cosmetics * * Revision 1.2  1998/06/24 17:38:54  meister * Legal boilerplate. * *//* [clearcase]modification history-------------------01a,19apr05,job  update copyright notices*/#include <types.h>#include <psos.h>#include <prepc.h>#include <gsblk.h>#include <disi.h>#include <diti.h>#include <string.h>#include <wrn/wm/common/config.h>#include <wrn/wm/attache/config.h>#include <wrn/wm/demo/bug_conf.h>#include <wrn/wm/common/bug.h>#include <wrn/wm/attache/psos/nidrv.h>#include <sys_conf.h>#include <wrn/wm/demo/psosinit.h>#ifndef INSTALL_SNARK_PSOSTTY_PC_CONSOLE#define INSTALL_SNARK_PSOSTTY_PC_CONSOLE \  (defined(BSP_CPUFAMILY) && defined(FAMILY_X86) && \   defined(SC_APP_CONSOLE) && defined(PCCON) && \   (BSP_CPUFAMILY == FAMILY_X86) && (SC_APP_CONSOLE == PCCON))#endif#ifndef INSTALL_SNARK_PSOSTTY_SIM_CONSOLE#define INSTALL_SNARK_PSOSTTY_SIM_CONSOLE \     (defined(BSP_CPUFAMILY) && defined(FAMILY_PSOSIM) && \      (BSP_CPUFAMILY == FAMILY_PSOSIM))#endif     #if INSTALL_SNARK_PSOSTTY_PC_CONSOLE #include <../devices/common/pcconsol.h>#endifextern void (*kbd_handler)(unsigned char *, size_t);static void kbd_read_task (void);#define CLIENT_USRSTACK   1024      /* User stack size of  client task */#define CLIENT_SYSSTACK   4096      /* Supervisor stack size */#define CLIENT_FLAGS      0x00      /* Flags for client task */#define CLIENT_INITMODE   T_SUPV    /* Initial mode of the client task *//*  * put console in non-echo, non blocking mode.  * The PC console code is somewhat black magic, depending on calls in the  * the pc console device driver module that aren't documented in the pSOS  * documentation. set INSTALL_SNARK_PSOS_NO_PC_CONSOLE_ECHO_MAGIC in your  * config file to turn it off. */void term_setup (void){#if !INSTALL_SNARK_PSOSTTY_PC_CONSOLE && !INSTALL_SNARK_PSOSTTY_SIM_CONSOLE     struct ioparms parms;     ULONG iopb [4];     TermCtl tctl;     struct termio tio;     parms.in_iopb = iopb;     parms.in_dev = CONSOLE;     parms.tid = 0L;          TermInit (&parms);     BUG(BUG_SNARK_PSOSTTY_INFO, BUG_CONTINUABLE, (void *) 0,         (BUG_OUT, "term_init returned %ld for err, %ld for retval",                    parms.err, parms.out_retval));     parms.in_iopb = (ULONG *) &tctl;     tctl.function = TCGETS;     tctl.arg = &tio;     TermIoctl (&parms);     BUG(BUG_SNARK_PSOSTTY_INFO, BUG_CONTINUABLE, (void *) 0,         (BUG_OUT, "TermIoctl returned %ld for err, %ld for retval",                    parms.err, parms.out_retval));          tio.c_lflag &= ~(ICANON|ECHO);     tio.c_cc[VMIN] = 1;     tio.c_cc[VTIME] = 0;     tctl.function = TCSETS;     TermIoctl (&parms);     BUG(BUG_SNARK_PSOSTTY_INFO, BUG_CONTINUABLE, (void *) 0,         (BUG_OUT, "TermIoctl returned %ld for err, %ld for retval",                    parms.err, parms.out_retval));#elif INSTALL_SNARK_PSOSTTY_PSOS_CONSOLE && !INSTALL_SNARK_PSOS_NO_PC_CONSOLE_ECHO_MAGIC     struct ioparms parms;     struct pccnsl_ctl_iopb cons_iopb;     cons_iopb.function = PCCNSL_GET_PARMS;     parms.in_iopb = (ULONG *) &cons_iopb;     PcCnslCntrl (&parms);     if (cons_iopb.parms.echo == TRUE)     {         BUG(BUG_SNARK_PSOSTTY_INFO, BUG_CONTINUABLE, (void *) 0,             (BUG_OUT, "pc console ECHO mode starts out ON"));     }     else     {         BUG(BUG_SNARK_PSOSTTY_INFO, BUG_CONTINUABLE, (void *) 0,             (BUG_OUT, "pc console ECHO mode starts out OFF"));     }     cons_iopb.parms.echo = 0;     cons_iopb.function = PCCNSL_SET_PARMS;     PcCnslCntrl (&parms);     cons_iopb.function = PCCNSL_GET_PARMS;     PcCnslCntrl (&parms);     if (cons_iopb.parms.echo == TRUE)     {         BUG(BUG_SNARK_PSOSTTY_INFO, BUG_CONTINUABLE, (void *) 0,             (BUG_OUT, "pc console ECHO mode ends up ON"));     }     else     {         BUG(BUG_SNARK_PSOSTTY_INFO, BUG_CONTINUABLE, (void *) 0,             (BUG_OUT, "pc console ECHO mode ends up OFF"));     }#endif /* !INSTALL_SNARK_PSOSTTY_PC_CONSOLE */}     /* * write a character string to the serial console */static int psos_console_write (char *txt, int len){#if INSTALL_SNARK_PSOSTTY_PC_CONSOLE || INSTALL_SNARK_PSOSTTY_SIM_CONSOLE     ULONG ioretval, iopb[4], rc;     iopb[0] = len;     iopb[1] = (ULONG) txt;     rc = de_write(CONSOLE, iopb, &ioretval);     return (int) rc;#else /* INSTALL_SNARK_PSOSTTY_PC_CONSOLE */     struct ioparms parms;     TermIO tioblk;     parms.in_dev = CONSOLE;     parms.tid = 0L;          tioblk.length = len;     tioblk.buffp = txt;     parms.in_iopb = (ULONG *) &tioblk;     TermWrite (&parms);     return parms.out_retval;#endif /* INSTALL_SNARK_PSOSTTY_PC_CONSOLE */}void keyboard_write(unsigned char *text, size_t length){  (void) psos_console_write ((char *) text, (int) length);}static unsigned long kbd_send_queue = 0L;static unsigned long kbd_send_task = 0L;static unsigned long AttKbdTaskId  = 0L;unsigned long CreateKbdTask (unsigned long priority,                             unsigned long kbd_queue_id,                              unsigned long attache_task_id){     if (t_create("AKBD", priority, CLIENT_SYSSTACK, CLIENT_USRSTACK,                  CLIENT_FLAGS, &AttKbdTaskId) != 0)     {         BUG(BUG_SNARK_PSOSTTY_INFO, BUG_CONTINUABLE, (void *) 0,             (BUG_OUT, "Task creation error (AKBD)"));         return 0;     }     kbd_send_queue = kbd_queue_id;     kbd_send_task  = attache_task_id;     return AttKbdTaskId;}int StartKbdTask (){  unsigned long i;   if (t_start(AttKbdTaskId, CLIENT_INITMODE, kbd_read_task, &i) != 0)   {        BUG(BUG_SNARK_PSOSTTY_INFO, BUG_CONTINUABLE, (void *) 0,           (BUG_OUT, "AKBD task start error"));   }   return 0;}static void kbd_read_task (void){    unsigned long msg[4];    unsigned char c;    while (1)      {#if INSTALL_SNARK_PSOSTTY_PC_CONSOLE || INSTALL_SNARK_PSOSTTY_SIM_CONSOLE	ULONG ioretval, iopb[4]; 	iopb[0] = 1;	iopb[1] = (ULONG) &c;	de_read (CONSOLE, iopb, &ioretval);#else	struct ioparms parms;	TermIO tioblk;	tioblk.length = 1;	tioblk.buffp = &c;	parms.in_iopb = (ULONG *)&tioblk;	parms.in_dev = CONSOLE;	TermRead(&parms);	if (parms.err)	  {	    BUG(BUG_SNARK_PSOSTTY_INFO, BUG_CONTINUABLE, (void *) 0,		(BUG_OUT, "kbd_task TermRead failed, code %lx",		 parms.err));	    continue;	  }#endif	/* If no receiver yet, drop char into bit bucket.. */	if (kbd_send_task)	  {	    MEMSET(msg, 0, sizeof(msg));	    SET_ATTACHE_PSOS_MSG_OPCODE(msg, ATTACHE_PSOS_MSG_KBDCHAR);	    SET_ATTACHE_PSOS_MSG_CHAR(msg, c);	    q_send(kbd_send_queue, msg);	    ev_send(kbd_send_task, ATTACHE_PSOS_QEVENT);	  }      }    /* NOTREACHED */        t_suspend (0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -