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

📄 allports.c

📁 internich公司实现的一个非常非常小的OS
💻 C
字号:
/* * FILENAME: allports.c * * Copyright 1998- 2004 By InterNiche Technologies Inc. All rights reserved * * Routines common to most targets.  * * MODULE: MISCLIB * * ROUTINES: netmain_init(), prep_modules(), station_state(),  * ROUTINES: station_state(), sysuptime() * * The functions in this file are generic functions  * and hence used for all builds. In addition to the above functions, * globals "name" and "prompt" are also initialized in this file. * * PORTABLE: yes * They are portable for all targets that InterNiche supports. In future * if there is need for any of them  to be made target-specific, then * #ifndef wrappers can be provided over here. */#include "license.h"#include "ipport.h"#ifdef USE_MODEM#include "mdmport.h"#else#endif   /* USE_MODEM */#include "menu.h"#ifdef OSPORT_H#include OSPORT_H#endif#ifdef TK_STDIN_DEVICEextern   void  kbdio(void);#endif#ifdef TESTMENU   /* after menus.h */extern   struct menu_op testmenu[10];#endif   /* TESTMENU */void task_stats(void * pio);
/* The following global variables are used in most ports. They are used by code * covered under a variety of ipport.h feature ifdefs. Experience has show that * it's not practical to do a complete ifdef to omit these when they are not * in use. It would require a huge multiple OR case, and many preprocessors * don't handle ifdef logic that complex. */char * name = "Open Source NicheTask from InterNiche, v1.0\n";char * prompt = "NicheTask> ";     /* prompt for console */
#ifdef USE_COMPORT#include "comline.h"          /* include if not yet included *//* Struct contaning all configuration global params for Comport */struct ComPortCfg comportcfg;#endif   /* USE_COMPORT *//* FUNCTION: netmain_init() *  * Initialize all the modules that are being compiled in. * This function is generic and is required for all builds * * Tasks do their own initialization. Hence for modules which have * their own tasks, we don't do the initialization in netmain_init().  * That is done by putting then under "#ifdef SUPERLOOP" *  * PARAM1:  * * RETURNS:  */void netmain_init(void){   int   e = 0;   int   i = 0;   char *   msg;   printf("%s\n", name);   printf("Copyright 1996-2003 by InterNiche Technologies. All rights reserved. \n");   /* call this to do pre-task setup including intialization of port_prep */   msg = pre_task_setup();   if (msg)      panic(msg);#ifndef INCLUDE_NVPARMS#ifdef USE_COMPORT   comportcfg.comport = 0x01;#endif   /* USE_COMPORT */#endif   /* INCLUDE_NVPARMS */   /* call this per-target routine after basic tasks & net are up */   msg = post_task_setup();   if (msg)      panic(msg);#ifdef TESTMENU   install_menu(testmenu);#endif   /* TESTMENU */#ifdef IN_MENUS   printf(prompt);#endif   USE_ARG(e);    /* Avoid compiler warnings */   USE_ARG(i);} /* end of netmain_init() *//* FUNCTION: station_state() * * state() - printf some info about the current state of the user  * settable station variables.  *  * PARAM1: void * pio * * RETURNS:  */intstation_state(void * pio){   ns_printf(pio, "current tick count %lu\n", cticks);   task_stats(pio);   return 0;}#ifndef NO_INET_STACK   /* these functions are pretty stack-centric *//* FUNCTION: sysuptime() *  * sysuptime() - return MIB-2 sys group compatable "sysUptime" value * * PARAM1:  * * RETURNS:  */unsigned longsysuptime(){   return ((cticks/TPS)*100);    /* 100ths of a sec since boot time */}int prep_modules(void){int e = 0;#ifdef USE_PPP   e = ppp_setup();   if (e != 0)   {      dprintf("PPP Module setup failed\n");      panic("prep_modules");   }#endif   /* USE_PPP */#ifdef USE_MODEM   e = prep_modem();   if (e != 0)   {      dprintf("Modem Module prep failed\n");      panic("prep_modules");   }#endif   /* USE_MODEM */#ifdef TELNET_SVR   e = prep_telnet();   if (e != 0)   {      dprintf("Telnet Module prep failed\n");      panic("prep_modules");   }#endif   /* TELNET_SVR */#ifdef DHCP_SERVER   e = prep_dhcpsrv();   if (e != 0)   {      dprintf("DHCP Server Module prep failed\n");      panic("prep_modules");   }#endif   /* DHCP_SERVER */#ifdef NATRT   e = prep_natrt();   if (e != 0)   {      dprintf("Nat Router Module prep failed\n");      panic("prep_modules");   }#endif   /* NATRT */#ifdef RIP_SUPPORT   e = prep_rip();   if (e != 0)   {      dprintf("Rip Module prep failed\n");      panic("prep_modules");   }#endif   /* RIP_SUPPORT */#ifdef INCLUDE_SNMP   e = prep_snmp();   if (e != 0)   {      dprintf("SNMP Module prep failed\n");      panic("prep_modules");   }#endif   /* INCLUDE_SNMP */#ifdef SMTP_ALERTS   e = prep_smtp();   if (e != 0)   {      dprintf("SMTP Module prep failed\n");      panic("prep_modules");   }#endif   /* SMTP_ALERTS */#ifdef VFS_FILES   e = prep_vfs();   if (e != 0)   {      dprintf("VFS Module prep failed\n");      panic("prep_modules");   }#endif   /* VFS_FILES */#ifdef FTP_CLIENT   e = prep_ftpc();   if (e != 0)   {      dprintf("FTP Client Module prep failed\n");      panic("prep_modules");   }#endif   /* FTP_CLIENT */   USE_ARG(e);   return 0;}#endif   /* NO_INET_STACK */

⌨️ 快捷键说明

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