📄 snrkpsos.c
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/lib/snrkpsos.c,v 1.3 2003/01/15 14:04:36 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 1993-1997 Epilogue Technology Corporation. * Copyright 1998 Integrated Systems, Inc. * All rights reserved. ****************************************************************************//* * $Log: snrkpsos.c,v $ * Revision 1.3 2003/01/15 14:04:36 josh * directory structure shifting * * Revision 1.2 2001/11/08 15:56:27 tneale * Updated for newest file layout * * Revision 1.1.1.1 2001/11/05 17:48:43 tneale * Tornado shuffle * * Revision 1.41 2001/06/12 15:57:53 paul * Removed some private debugging code that crept in. * * Revision 1.40 2001/06/12 08:06:26 paul * Seize the Attache lock before calling attache_init(). * Init the debug stuff first, so we can debug subsequent init code. * Be more careful with condition variables. * * Revision 1.39 2001/02/09 20:14:05 paul * Trivial cleanup. * * Revision 1.38 2001/01/19 22:23:54 paul * Update copyright. * * Revision 1.37 2000/10/16 19:21:55 paul * Restore sockets and mempool code. * * Revision 1.36 2000/03/17 00:12:46 meister * Update copyright message * * Revision 1.35 2000/03/13 21:22:10 paul * Removed some code that we are no longer working on. * * Revision 1.34 1999/04/15 21:38:25 wes * Use symbolic values for flag bits * * Revision 1.33 1999/04/15 17:48:39 wes * Pick up task loop changes similar to recent ones to snarkbsd.c in the * ATTACHE_THREADS case (neatening it up before burial). * * Revision 1.32 1999/04/15 15:45:31 wes * Catch null function pointers with a BUG_ASSERT instead of blithely * leaping into the void. * * Revision 1.31 1999/04/09 21:28:57 wes * clean up isascii prototype and definition. * * Revision 1.30 1999/02/22 21:31:56 wes * let the ATTACHE_THREADS case work again. * * Revision 1.29 1999/02/18 04:41:36 wes * Sockets merge: Everything Else * - memory pools * - thread support * - port-specific headers * * Revision 1.28 1998/12/16 09:09:07 sra * Add magic multicast support for Courier. Change opcode for packet receive * events to avoid customers handing unencapsulated IP packets to et_rcv(). * * Revision 1.27 1998/12/12 18:53:40 sra * Changes to pSOS port of Attache: support non-Ethernet NI drivers, * simplify packet buffer implementation, general cleanup. * * Revision 1.26 1998/09/29 20:10:13 meister * delete unused glue_free() code * * Revision 1.25 1998/09/25 21:23:26 meister * queue attache callbacks onto the attache queue such that they are invoked by * same task as is usually calling attache. Fixes re-entrancy bug which crept * in when MUXD task went away and i consolidated timers. * * Revision 1.24 1998/09/22 21:57:53 meister * glue_pktalloc, glue_pktfree, glue_intlock really belong in attache/psos, * not snark/lib for this port. * * Revision 1.23 1998/09/22 19:39:26 wes * Since, at startup, there's a task already queued for us, check the task * queue at the top of the loop instead of the bottom.. * * Revision 1.22 1998/09/18 18:52:05 meister * consolidation based on Qing code review * * Revision 1.21 1998/09/15 20:40:20 meister * attache timer is NIDD task's responsibility now * * Revision 1.20 1998/09/15 19:49:55 meister * tweaks to allow single callback function for all pSOS NI's * * Revision 1.19 1998/09/11 19:16:31 meister * handle non-zero-copy NI drivers; pass NI flags into add_psos_nidrv_iface * * Revision 1.18 1998/09/09 16:35:02 meister * changes for multiple NI drivers * * Revision 1.17 1998/09/03 22:19:31 meister * tweaks to populate_attache_ni_table () * * Revision 1.16 1998/08/07 18:50:17 meister * no more esysconf.h * * Revision 1.15 1998/08/04 22:53:03 meister * changed PEV_QEVENT, MSG_KBDCHAR, etc to have better attache_specific names * * Revision 1.14 1998/08/03 20:46:39 meister * changed declaration for NiLan to BSP_LAN1_ENTRY * * Revision 1.13 1998/08/01 19:44:54 sra * Swap routines live in their own file now. * * Revision 1.12 1998/07/30 22:17:25 meister * simplified add_psos_nidrv_interface(), moved to attache/psos directory * * Revision 1.11 1998/07/24 21:04:02 meister * Added psostty.c * moved nidrive.c to attache/psos * * Revision 1.10 1998/07/17 18:58:43 sra * Swap and checksum routines moved to separate files. * * Revision 1.9 1998/07/14 00:16:19 sra * Use <common/h/config.h>. * * Revision 1.8 1998/07/10 21:52:52 meister * netconfig_find searches through a constructed-at-run-time attache NI table * * Revision 1.7 1998/07/02 06:55:39 sra * Make Snark restartable under pSOS, and other minor cleanups. * * Revision 1.6 1998/06/23 17:51:30 meister * deleted unneeded attache/h/ip.h * * Revision 1.5 1998/06/08 22:05:46 meister * added "unlink" wrapper [calls pHILE remove_f () call] * * Revision 1.4 1998/06/04 23:04:44 meister * strncasecmp shim * * Revision 1.3 1998/05/13 21:18:33 meister * removed some debug code * * Revision 1.2 1998/04/29 23:15:11 meister * Configuration via etc.ini added (over pHILE ramdisk) * * Revision 1.1 1998/04/24 22:04:19 meister * Initial checkin of snark pSOS port * * Initial revision meister * *//* [clearcase]modification history-------------------01a,19apr05,job update copyright notices*//* * Implementation of snark for pSOS with Bala's NI shim */#include <wrn/wm/common/config.h>#include <wrn/wm/common/glue.h>/* * the following are pSOS specific include files, which should be found by the * Diab or other pSOS cross-compiler being used. */#include <psos.h> #include <prepc.h> #if INSTALL_SNARK_PSOS_NEEDS_UNLINK#include <phile.h> #endif#include <gsblk.h>#include <sys_conf.h>/* * end of pSOS specific includes */#include <wrn/wm/demo/bug_conf.h>#include <wrn/wm/demo/psosinit.h>#if INSTALL_ATTACHE#include <wrn/wm/attache/config.h>#include <wrn/wm/attache/mib.h>#include <wrn/wm/attache/timer.h>#include <wrn/wm/attache/packet.h>#include <wrn/wm/attache/net.h>#include <wrn/wm/attache/glue.h>#include <wrn/wm/attache/loop.h>#include <wrn/wm/attache/ether.h>#include <wrn/wm/attache/arp.h>#include <wrn/wm/attache/attthd.h>#endif#if INSTALL_ENVOY#include <wrn/wm/snmp/engine/snmpdefs.h>#endif#include <stdio.h>#include <stdlib.h>#include <stdarg.h>#include <wrn/wm/demo/snarklib.h>#include <wrn/wm/attache/psos/nidrv.h>#if INSTALL_ATTACHE#include <wrn/wm/demo/netconf.h>#endif/* * These are defined here rather than in snark/lib/main.c so that this * code can be used without that module if the customer so desires. */int snark_exit_flag, snark_exit_value;extern int psos_kbd_getch (void);extern int psos_kbhit (void);/* * This function processes a system time received from SNTP. Because we * are in a simulator, we don't want to set the real system time. The * time is represented as seconds (secs) and fractions of a second * (fracs) since 00:00:00 1/1/1900. This is the standard NTP time * representation described in RFC 2030 and others. * * This function is handed the entire SNTP packet, because it is * likely that a real SNTP client would want to enforce some sort * of policy regarding what time sources to believe. */void glue_set_time(packet *p, bits32_t secs, bits32_t fracs){ /* adjust NTP time representation to Unix time representation. This * method is good enough for most purposes, but not perfect. */ secs -= (bits32_t)2208988800UL; printf("\nThe time is: %lu (in UNIX time seconds)\n", secs);}/* Low-level keyboard handler stuff. */void (*kbd_handler)(unsigned char *, size_t);void keyboard_handler(void (*handler)(unsigned char *, size_t)){ kbd_handler = handler;}#if INSTALL_ATTACHE/* * Network configuration. */extern long BSP_LAN1_ENTRY(unsigned long, void *);extern long BSP_LAN2_ENTRY(unsigned long, void *);extern long NiSlip(unsigned long, void *);extern long NiPPP(unsigned long, void *);static void netconfig_find_one(bits16_t flags, int ha_len, bits32_t speed, long (*nidriver)(unsigned long, void *), int nidrv_flags, int nidrv_instance){ net_if *interface; int err; interface = add_psos_nidrv_interface (flags, ha_len, speed, nidriver, nidrv_flags, nidrv_instance, &err); if (!interface) { /* This should use BUG() */ printf ("Error %d configuring pSOS NI driver interface %d\n", err, nidrv_instance); return; } if (netconfig_if (interface)) { if_attach(interface); if_up(interface); }}void netconfig_find(){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -