vxworks常用数据结构

基本数据结构
typedef struct node/* Node of a linked list. */
{
struct node *next;/* Points at the next node in the list */
struct node *previous;/* Points at the previous node in the list */
} NODE;

typedef struct/* Header for a linked list. */
{
NODE node;/* Header list node */
int count;/* Number of nodes in list */
} LIST;

typedef struct dlnode/* Node of a linked list. */
{
    struct dlnode *next;/* Points at the next node in the list */
    struct dlnode *previous;/* Points at the previous node in the list */
} DL_NODE;

typedef struct/* Header for a linked list. */
    {
    DL_NODE *head;/* header of list */
    DL_NODE *tail;/* tail of list */
} DL_LIST;

 
网络相关

1.LIST hostList  
整个系统的host, hostAdd()产生. hostShow()产看.其中的表项为

typedef struct
    {
    NODE node; /*
节点链
*/
    HOSTNAME hostName;/*
名称
*/
    struct in_addr netAddr;/*
网络地址
*/
    } HOSTENTRY;
char targetName [HOSTNAME_LEN];/* name for this target machine */

2.LIST endList
整个系统已加载的end, muxDevLoad()产生,endFindByName()查看.其中表项为
:
typedef struct end_tbl_row
    {
    NODE node;                  /* Needed by our list processing library. */
    char name[END_NAME_MAX];/* Name of the devices in row. (ln, etc.) */
    LIST units;                 /* List of devices, i.e. 0, 1, etc..  */
    } END_TBL_ROW;
units
链表中包含的是真正的
END_OBJ.
3.END_TBL_ENTRY endDevTbl[]
整个系统要加载的end,加载后便进入endList.其中表项为
:
typedef struct end_tbl_entry
    {
    int unit;                                /* This device's unit # */
    END_OBJ* (*endLoadFunc) (char*, void*);         /* The Load function. */
    char* endLoadString;                     /* The load string. */
    BOOL endLoan;                            /* Do we loan buffers? */
    void* pBSP;                              /* BSP private */
    BOOL processed;                          /* Has this been processed? */
    } END_TBL_ENTRY;

4._netDpool(_pNetDpool)  _netSysPool(_pNetSysPool)
系统网络缓冲区.netLibInit()->netLibGeneralInit()->mbinit()中初始化
.
_netDPool(_pNetSysPool) 
Only used for data transfer in the network stack.
_netsyspool(_pNetDpool) 
Used for network stack system structures such as routes, sockets, protocol control blocks, interface addresses, mulitcast addresses,and multicast routing entries.

5.struct ifnet *ifnet;/* list of all network interfaces */
网络接口链表可以使用ifShow()通过遍历ifp->if_next查看整个表if_attach(ifp)加入一个. ipAttach()内部调用了
if_attach().
IP
层自己有一个IP_DRV_CTRL ipDrvCtrl[IP_MAX_UNITS], 其中包含了
struct ifnet.

最后一个成员是
:
structifqueue if_snd;/* output queue */

6.UDP
TCP都有in_pcb的链表,指向每个socket
so_pcb.
struct inpcb 
{
LIST_ENTRY(inpcb) inp_list;/* list for all PCBs of this proto */
LIST_ENTRY(inpcb) inp_hash;/* hash list */
structinpcbinfo *inp_pcbinfo;

structin_addr inp_faddr;/* foreign host table entry */
u_shortinp_fport;/* foreign port */

structin_addr inp_laddr;/* local host table entry */
u_shortinp_lport;/* local port */

structsocket *inp_socket;/* back pointer to socket */
caddr_tinp_ppcb;/* pointer to per-protocol pcb */
structroute inp_route;/* placeholder for routing entry */
intinp_flags;/* generic IP/datagram flags */
structip inp_ip;/* header prototype; should have more */
structmbuf *inp_options;/* IP options */
structip_moptions *inp_moptions; /* IP multicast options */
};
 

7.struct protosw inetsw [IP_PROTO_NUM_MAX]  Protocol switch table,
存放各种协议的函数
.
Each protocol has a handle initializing one of these structures,
which is used for protocol-protocol and system-protocol communication.
Protocols pass data between themselves as chains of mbufs using the pr_input and pr_output hooks.

pr_input
的调用

ipintr()
{
(*inetsw[ip_protox[ip->ip_p]].pr_input) (m, hlen); 
}

struct protosw
  {
    shortpr_type;/* socket type used for */
    structdomain *pr_domain;/* domain protocol a member of */
    shortpr_protocol;/* protocol number */
    shortpr_flags;/* see below */

    void(*pr_input) ();/* input to protocol (from below) */
    int(*pr_output) ();/* output to protocol (from above) */
    void(*pr_ctlinput) ();/* control input (from below) */
    int(*pr_ctloutput) ();/* control output (from above) */
    int(*pr_usrreq) ();/* user request: see list below */

    void(*pr_init) ();/* initialization hook */
    void(*pr_fasttimo) ();/* fast timeout (200ms) */
    void(*pr_slowtimo) ();/* slow timeout (500ms) */
    void(*pr_drain) ();/* flush any excess space possible */
    int(*pr_sysctl) ();/* sysctl for protocol */
};

ipLibInit(),icmpLibInit(),igmpLibInit(),udpLibInit(),tcpLibInit()等都会有一个
protosw.
{
pProtoSwitch
->pr_type=  (0,SOCK_RAW , SOCK_RAW , SOCK_DGRAM, SOCK_STREAM)
    ->pr_domain=  &inetdomain;
    ->pr_protocol=  (IPPROTO_IP, IPPROTO_ICMP, IPPROTO_IGMP,IPPROTO_UDP, IPPROTO_TCP)
    ->pr_flags=  PR_ATOMIC | PR_ADDR;
    ->pr_input=  (0, icmp_input , igmp_input ,udp_input,tcp_input);
    ->pr_output=  (ip_output , rip_output, rip_output, 0,0);
    ->pr_ctlinput=  udp_ctlinput;
    ->pr_ctloutput=  ip_ctloutput;
    ->pr_usrreq=  udp_usrreq;
    ->pr_init=  udp_init;
_protoSwIndex++;
}
8.struct domain *domains;/* list of domain descriptors */
    
addDomain (struct domain * pDomain)添加一个新的域
.
系统预定义的一个域为
:
struct domain inetdomain =
     {
  AF_INET, "internet", 0, 0, 0, 
        inetsw, &inetsw[sizeof(inetsw)/sizeof(inetsw[0])], 0,
        rn_inithead, 27, sizeof(struct sockaddr_in) 
};
9.RIP ripState;
整个系统的rip状态
.

10.struct radix_node_head *rt_tables[]
整个系统的路由表.可以有很多种,
rt_tables[AF_INET].

中断相关

11.INTR_HANDLERintrVecTable[NUM_VEC_MAX]/*  Intr vector table */
MPC860 core
的外部中断表中断定位在0x500.intConnect()加入中断,ppc860IntrDeMux()相应中断并分解响应
.

设备相关

12.DL_LIST iosDvList
所有已安装的deviceiosDevAdd()添加一个表项, iosDelete()删除一个表项.表项为
:
typedef struct /* DEV_HDR - device header for all device structures */
{
    DL_NODEnode;/* device linked list node */
    shortdrvNum;/* driver number for this device,
指向drvTable[]相应的位置
 */
    char *name;/* device name */
} DEV_HDR;
 

13.DRV_ENTRY drvTable[NUM_DRIVERS] /* max 20 drivers in drvTable */
所有硬件驱动表.iosDrvInstall()添加表项.其中表项为
:
typedef struct/* DRV_ENTRY - entries in driver jump table */
    {
    FUNCPTRde_create;
    FUNCPTRde_delete;
    FUNCPTRde_open;
    FUNCPTRde_close;
    FUNCPTRde_read;
    FUNCPTRde_write;
    FUNCPTRde_ioctl;
    BOOLde_inuse;
    } DRV_ENTRY;
 
14.FD_ENTRY fdTable[NUM_FILES] /* max 50 files open simultaneously */
所有打开的文件描述符表.fopen()添加一个表项,fclose()删除一个表项.其中表项为
:
typedef struct/* FD_ENTRY - entries in file table */
    {
    DEV_HDR *pDevHdr;/* device header for this file */
    int value;/* driver's id for this file */
    char *name;/* actual file name */
    BOOL inuse;/* active entry */
} FD_ENTRY;

其他

15.
#define BOOT_LINE_OFFSET 0x4200
#define BOOT_LINE_ADRS((char *) (LOCAL_MEM_LOCAL_ADRS+BOOT_LINE_OFFSET))
#define DEFAULT_BOOT_LINE "ide=0,0(0,0)host:/vxWorks.dat  f=0x8 tn=HC3600 o=cpm"
启动时,如果用户没有输入boot参数,系统便把DEFAULT_BOOT_LINE拷贝到BOOT_LINE_ADRS 整个系统使用.

 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值