它山之石可以攻玉 https://bbs.21ic.com/?12980 [收藏] [复制] [RSS]

日志

Keil RV好像不支持自带的TcpNet,Flash File System

已有 3652 次阅读2006-4-14 21:10 |个人分类:ARM应用|系统分类:ARM

当选用keil CARM时,头文件如下:


/*----------------------------------------------------------------------------
 *      A R T X  -  A P I
 *----------------------------------------------------------------------------
 *      Name:    ARTX.H
 *      Purpose: Application Programming Interface.
 *      Rev.:    V2.02 / 6-feb-2006
 *----------------------------------------------------------------------------
 *      This code is part of the ARTX-ARM kernel package of Keil Software.
 *      Copyright (c) 2004-2006 Keil Software. All rights reserved.
 *---------------------------------------------------------------------------*/


#ifndef __ARTX_H__
#define __ARTX_H__


#ifndef NULL
 #ifdef __cplusplus              // EC++
   #define NULL   0
 #else
   #define NULL   ((void *) 0)
 #endif
#endif


#ifndef EOF
 #define EOF -1
#endif


#ifndef __SIZE_T__
 #define __SIZE_T__
 typedef unsigned int size_t;
#endif


#ifndef __ARTX_EXT__
 #define __ARTX_EXT__
 typedef char           S8;
 typedef unsigned char  U8;
 typedef short          S16;
 typedef unsigned short U16;
 typedef int            S32;
 typedef unsigned int   U32;
 typedef unsigned char  BIT;
 typedef unsigned int   BOOL;
 #ifndef __TRUE
  #define __TRUE        1
 #endif
 #ifndef __FALSE
  #define __FALSE       0
 #endif
#endif


/*----------------------------------------------------------------------------
 *                             ARTX Kernel API
 *---------------------------------------------------------------------------*/


#ifdef __cplusplus               // EC++
extern "C"  {
#endif


/* Definition of Semaphore type */
typedef U32 OS_SEM[2];


/* Definition of Mailbox type */
#define os_mbx_declare(name,cnt)    U32 name [4 + cnt]
typedef U32 OS_MBX[];


/* Definition of Mutex type */
typedef U32 OS_MUT[3];


#ifndef OS_R_TMO
 /* Task Identification number. */
 typedef U32 OS_TID;


 /* Function return of system calls returning an object identification */
 typedef void *OS_ID;


 /* Function return of system calls indicating an event or completion state */
 typedef U32 OS_RESULT;


 /* Return codes */
 #define OS_R_TMO        0x01
 #define OS_R_EVT        0x02
 #define OS_R_SEM        0x03
 #define OS_R_MBX        0x04
 #define OS_R_MUT        0x05


 #define OS_R_OK         0x00
 #define OS_R_NOK        0xff
#endif


/*----------------------------------------------------------------------------
 *      Functions
 *---------------------------------------------------------------------------*/



/* Task Management */
#define os_sys_init(tsk)                os_sys_init_user(tsk,0,NULL,0)
#define os_sys_init_prio(tsk,prio)      os_sys_init_user(tsk,prio,NULL,0)
#define os_tsk_create(tsk,prio)         os_tsk_create_user(tsk,prio,NULL,0)
#define os_tsk_create_ex(tsk,prio,argv) os_tsk_create_user_ex(tsk,prio,NULL,0,argv)
#define os_tsk_delete_self()            os_tsk_delete(0)
#define os_tsk_prio_self(prio)          os_tsk_prio(0,prio)


extern OS_TID os_tsk_create_user (void (*task)(void), U8 priority,
                                  void *stk, U16 size);
extern OS_TID os_tsk_create_user_ex (void (*task)(void *), U8 priority,
                                     void *stk, U16 size, void *argv);
extern OS_TID os_tsk_self (void);
extern void os_sys_init_user (void (*task)(void), U8 priority, void *stk, U16 size);
extern void os_tsk_pass (void);
extern OS_RESULT os_tsk_prio (OS_TID task_id, U8 new_prio);
extern OS_RESULT os_tsk_delete (OS_TID task_id);


/* Event flag Management */
#define os_evt_wait_or(wflags,tmo)      os_evt_wait(wflags,tmo,__FALSE)
#define os_evt_wait_and(wflags,tmo)     os_evt_wait(wflags,tmo,__TRUE)


extern OS_RESULT os_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait);
extern void os_evt_set (U16 event_flags, OS_TID task_id);
extern void os_evt_clr (U16 clear_flags, OS_TID task_id);
extern void isr_evt_set (U16 event_flags, OS_TID task_id);
extern U16  os_evt_get (void);


/* Semaphore Management */
extern void os_sem_init (OS_ID semaphore, U16 token_count);
extern OS_RESULT os_sem_send (OS_ID semaphore);
extern OS_RESULT os_sem_wait (OS_ID semaphore, U16 timeout);
extern void isr_sem_send (OS_ID semaphore);


/* Mailbox Management */
extern void os_mbx_init (OS_ID mailbox, U16 mbx_size);
extern OS_RESULT os_mbx_send (OS_ID mailbox, void *message_ptr, U16 timeout);
extern OS_RESULT os_mbx_wait (OS_ID mailbox, void  **message, U16 timeout);
extern OS_RESULT os_mbx_check (OS_ID mailbox);
extern void isr_mbx_send (OS_ID mailbox, void *message_ptr);
extern OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message);


/* Mutex Management */
extern void os_mut_init (OS_ID mutex);
extern OS_RESULT os_mut_release (OS_ID mutex);
extern OS_RESULT os_mut_wait (OS_ID mutex, U16 timeout);


/* Time Management */
extern void os_dly_wait (U16 delay_time);
extern void os_itv_set (U16 interval_time);
extern void os_itv_wait (void);


/* User Timer Management */
extern OS_ID os_tmr_create (U16 tcnt, U16 info);
extern OS_ID os_tmr_kill (OS_ID timer);


/* System Functions */
extern void tsk_lock (void);
extern void tsk_unlock (void);


/* Fixed Memory Block Management Functions */
extern int  _init_box  (void *box_mem, U32 box_size, U32 blk_size);
extern void *_alloc_box (void *box_mem)  __swi (6);
extern void *_calloc_box (void *box_mem);
extern int  _free_box (void *box_mem, void *box)  __swi (7);



/*----------------------------------------------------------------------------
 *                        ARTX Flash File System API
 *---------------------------------------------------------------------------*/


/* Definition of the control structure for streams */
struct _iobuf {
   U16   fileID;                        /* File Identification Number        */
   U16   flags;                         /* File status flags                 */
   U32   fpos;                          /* File position indicator           */
   int   cnt;                           /* Number of free bytes in a buffer  */
   char *ptr;                           /* Current active pointer            */
   char *base;                          /* Data transfer buffer              */
                                        /* --- Low level file variables ---- */
   U16   drive;                         /* Device Drive Media type           */
   U16   NumSect;                       /* Number of sectors                 */
   U32   InitVal;                       /* Initial content of Flash/RAM      */
   void *DevCfg;                        /* Device configuration              */
   U16   _fblock;                       /* Current Flash Block index         */
   U16   _fidx;                         /* Current File Block index          */
   U32   _fbot;                         /* Flash Block free space bottom     */
   U32   _ftop;                         /* Flash Block free space top        */
};
typedef struct _iobuf FILE;


typedef struct {                        /* File Search info record           */
   char  name[32];                      /* File name                         */
   long  size;                          /* File size in bytes                */
   int   fileID;                        /* System File Identification        */
} FINFO;


/* "flags" bit definitions  */
#define _IOREAD         0x0001
#define _IOWRT          0x0002
#define _IOAPPEND       0x0004
#define _IOEOF          0x0008
#define _IOERR          0x0010
#define _IOWALLOC       0x0020
#define _IORBUF         0x0040



/* Constants to be used as 3rd argument for "fseek" function */
#define SEEK_CUR        1
#define SEEK_END        2
#define SEEK_SET        0


extern FILE *fopen (const char *filename, const char *mode);
extern int  fclose (FILE *stream);
extern U32  fread (void *buffer, U32 size, U32 count, FILE *stream);
extern U32  fwrite (const void *buffer, U32 size, U32 count, FILE *stream);
extern int  fgetc (FILE *stream);
extern int  fputc (int c, FILE *stream);
extern char *fgets (char *string, int n, FILE *stream);
extern int  fputs (const char *string, FILE *stream);
extern int  fscanf (FILE *stream, const char *format, ... );
extern int  fprintf (FILE *stream, const char *format, ...);
extern int  fseek (FILE *stream, long offset, int origin);
extern int  fflush (FILE *stream);
extern void rewind (FILE *stream);
extern int  ungetc (int c, FILE *stream);
extern int  finit (void);
extern int  fdelete (const char *filename);
extern int  frename (const char *oldname, const char *newname);
extern int  ffind (const char *pattern, FINFO *info);
extern U32  ffree (const char *drive);
extern int  fformat (const char *drive);
extern int  fanalyse (const char *drive);
extern int  fcheck (const char *drive);
extern int  fdefrag (const char *drive);


/* The following macros provide for common functions */
#define ferror(f)       ((f)->flags & _IOERR)
#define feof(f)         ((f)->flags & _IOEOF)
#define ftell(f)        ((f)->fpos)
#define rename(o,n)     frename(o,n)
#define unlink(fn)      fdelete(fn);



/*----------------------------------------------------------------------------
 *                             ARTX TcpNet API
 *---------------------------------------------------------------------------*/


/* UDP Options */
#define UDP_OPT_SEND_CS 0x01      /* Calculate Checksum for UDP send frames  */
#define UDP_OPT_CHK_CS  0x02      /* Verify Checksum for received UDP frames */


/* TCP Socket Types */
#define TCP_TYPE_SERVER   0x01    /* Socket Type Server (open for listening) */
#define TCP_TYPE_CLIENT   0x02    /* Socket Type Client (initiate connect)   */
#define TCP_TYPE_CLIENT_SERVER (TCP_TYPE_SERVER | TCP_TYPE_CLIENT)


/* TCP Callback Events */
#define TCP_EVT_CONREQ    0       /* Connect request received event          */
#define TCP_EVT_CONNECT   1       /* Connection established event            */
#define TCP_EVT_CLOSE     2       /* Connection was properly closed          */
#define TCP_EVT_ABORT     3       /* Connection is for some reason aborted   */
#define TCP_EVT_ACK       4       /* Previously send data acknowledged       */
#define TCP_EVT_DATA      5       /* Data received event                     */


/* TCP States */
#define TCP_STATE_FREE     0      /* Entry is free and unused                */
#define TCP_STATE_CLOSED   1      /* Entry allocated, socket still closed    */
#define TCP_STATE_LISTEN   2      /* Socket waiting for incoming connection  */
#define TCP_STATE_SYN_REC  3      /* SYN frame received                      */
#define TCP_STATE_SYN_SENT 4      /* SYN packet sent to establish a connect. */
#define TCP_STATE_FINW1    5      /* Tcp_close started FIN packet was sent   */
#define TCP_STATE_FINW2    6      /* Our FIN ack-ed, waiting for remote FIN  */
#define TCP_STATE_CLOSING  7      /* Received FIN independently of our FIN   */
#define TCP_STATE_LAST_ACK 8      /* Waiting for last ACK for our FIN        */
#define TCP_STATE_TWAIT    9      /* Timed waiting for 2MSL                  */
#define TCP_STATE_CONNECT  10     /* TCP Connection established              */


/* DNS Callback Events */
#define DNS_EVT_SUCCESS   0       /* Host name successfully resolved         */
#define DNS_EVT_NONAME    1       /* DNS Error, no such name                 */
#define DNS_EVT_TIMEOUT   2       /* Timeout resolving host                  */
#define DNS_EVT_ERROR     3       /* Erroneous response packet               */


/* DNS 'get_host_by_name()' result codes */
#define DNS_RES_OK        0       /* Function finished OK                    */
#define DNS_ERROR_BUSY    1       /* DNS Client busy, can't process request  */
#define DNS_ERROR_LABEL   2       /* Host name Label too long                */
#define DNS_ERROR_NAME    3       /* Host name loo long                      */
#define DNS_ERROR_NOSRV   4       /* Prim. DNS server not specified (0.0.0.0)*/
#define DNS_ERROR_UDPSEND 5       /* UDP Send frame error                    */


/* SMTP Callback Events */
#define SMTP_EVT_SUCCESS   0      /* Email successfully sent                 */
#define SMTP_EVT_TIMEOUT   1      /* Timeout sending email                   */
#define SMTP_EVT_ERROR     2      /* Error when sending email                */


/* ARP Cache Entry types */
#define ARP_FIXED_IP    0         /* Fixed IP adrs is refreshed after tout   */
#define ARP_TEMP_IP     1         /* Temp adrs is removed after timeout      */


extern void init_TcpNet (void);
extern void main_TcpNet (void);
extern void timer_tick (void);
extern U8   udp_get_socket (U8 tos, U8 opt,
                            U16 (*listener)(U8 socket, U8 *remip, U16 port,
                                            U8 *buf, U16 len));
extern BOOL udp_release_socket (U8 socket);
extern BOOL udp_open (U8 socket, U16 locport);
extern BOOL udp_close (U8 socket);
extern U8  *udp_get_buf (U16 size);
extern BOOL udp_send (U8 socket, U8 *remip, U16 remport,
                      U8 *buf,   U16 dlen);
extern U8   tcp_get_socket (U8 type, U8 tos, U16 tout,
                            U16 (*listener)(U8 socket, U8 event, U8 *buf, U16 len));
extern BOOL tcp_release_socket (U8 socket);
extern BOOL tcp_listen (U8 socket, U16 locport);
extern BOOL tcp_connect (U8 socket, U8 *remip, U16 remport, U16 locport);
extern U8  *tcp_get_buf (U16 size);
extern U16  tcp_max_dsize (U8 socket);
extern BOOL tcp_check_send (U8 socket);
extern U8   tcp_get_state (U8 socket);
extern BOOL tcp_send (U8 socket, U8 *buf, U16 dlen);
extern BOOL tcp_close (U8 socket);
extern BOOL tcp_abort (U8 socket);
extern BOOL arp_cache_ip (U8 *ipadr, U8 type);
extern void ppp_listen (char const *user, char const *passw);
extern void ppp_connect (char const *dialnum, char const *user, char const *passw);
extern void ppp_close (void);
extern BOOL ppp_is_up (void);
extern void slip_listen (void);
extern void slip_connect (char const *dialnum);
extern void slip_close (void);
extern BOOL slip_is_up (void);
extern U8   get_host_by_name (U8 *hostn, void (*cbfunc)(U8 event, U8 *host_ip));
extern BOOL smtp_connect (U8 *ipadr, U16 port, void (*cbfunc)(U8 event));
extern void dhcp_disable (void);


#ifdef __cplusplus               // EC++
}
#endif


/*----------------------------------------------------------------------------
 * end of file
 *---------------------------------------------------------------------------*/
 
#endif
 


 


当选用RV时,头文件如下:


/*----------------------------------------------------------------------------
 *      R T L  -  A P I
 *----------------------------------------------------------------------------
 *      Name:    ARTX.H
 *      Purpose: Application Programming Interface.
 *      Rev.:    V2.10 / 30-jan-2006
 *----------------------------------------------------------------------------
 *      This code is part of the RealView Run-Time Library.
 *      Copyright (c) 2004-2006 KEIL - An ARM Company. All rights reserved.
 *---------------------------------------------------------------------------*/


#ifndef __ARTX_H__
#define __ARTX_H__


#ifndef __task
 #define __task
#endif


#ifndef NULL
 #ifdef __cplusplus              // EC++
   #define NULL   0
 #else
   #define NULL   ((void *) 0)
 #endif
#endif


#ifndef EOF
 #define EOF -1
#endif


#ifndef __SIZE_T__
 #define __SIZE_T__
 typedef unsigned int size_t;
#endif


#ifndef __ARTX_EXT__
 #define __ARTX_EXT__
 typedef char               S8;
 typedef unsigned char      U8;
 typedef short              S16;
 typedef unsigned short     U16;
 typedef int                S32;
 typedef unsigned int       U32;
 typedef long long          S64;
 typedef unsigned long long U64;
 typedef unsigned char      BIT;
 typedef unsigned int       BOOL;
 #ifndef __TRUE
  #define __TRUE        1
 #endif
 #ifndef __FALSE
  #define __FALSE       0
 #endif
#endif


/*----------------------------------------------------------------------------
 *                             ARTX Kernel API
 *---------------------------------------------------------------------------*/


#ifdef __cplusplus               // EC++
extern "C"  {
#endif


/* Definition of Semaphore type */
typedef U32 OS_SEM[2];


/* Definition of Mailbox type */
#define os_mbx_declare(name,cnt)    U32 name [4 + cnt]
typedef U32 OS_MBX[];


/* Definition of Mutex type */
typedef U32 OS_MUT[3];


#ifndef OS_R_TMO
 /* Task Identification number. */
 typedef U32 OS_TID;


 /* Function return of system calls returning an object identification */
 typedef void *OS_ID;


 /* Function return of system calls indicating an event or completion state */
 typedef U32 OS_RESULT;


 /* Return codes */
 #define OS_R_TMO        0x01
 #define OS_R_EVT        0x02
 #define OS_R_SEM        0x03
 #define OS_R_MBX        0x04
 #define OS_R_MUT        0x05


 #define OS_R_OK         0x00
 #define OS_R_NOK        0xff
#endif


/*----------------------------------------------------------------------------
 *      Functions
 *---------------------------------------------------------------------------*/



/* Task Management */
#define os_sys_init(tsk)                os_sys_init_user(tsk,0,NULL,0)
#define os_sys_init_prio(tsk,prio)      os_sys_init_user(tsk,prio,NULL,0)
#define os_tsk_create(tsk,prio)         os_tsk_create_user(tsk,prio,NULL,0)
#define os_tsk_create_ex(tsk,prio,argv) os_tsk_create_user_ex(tsk,prio,NULL,0,argv)
#define os_tsk_delete_self()            os_tsk_delete(0)
#define os_tsk_prio_self(prio)          os_tsk_prio(0,prio)


extern OS_TID os_tsk_create_user (void (*task)(void), U8 priority,
                                  void *stk, U16 size);
extern OS_TID os_tsk_create_user_ex (void (*task)(void *), U8 priority,
                                     void *stk, U16 size, void *argv);
extern OS_TID os_tsk_self (void);
extern void os_sys_init_user (void (*task)(void), U8 priority, void *stk, U16 size);
extern void os_tsk_pass (void);
extern OS_RESULT os_tsk_prio (OS_TID task_id, U8 new_prio);
extern OS_RESULT os_tsk_delete (OS_TID task_id);


/* Event flag Management */
#define os_evt_wait_or(wflags,tmo)      os_evt_wait(wflags,tmo,__FALSE)
#define os_evt_wait_and(wflags,tmo)     os_evt_wait(wflags,tmo,__TRUE)


extern OS_RESULT os_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait);
extern void os_evt_set (U16 event_flags, OS_TID task_id);
extern void os_evt_clr (U16 clear_flags, OS_TID task_id);
extern void isr_evt_set (U16 event_flags, OS_TID task_id);
extern U16  os_evt_get (void);


/* Semaphore Management */
extern void os_sem_init (OS_ID semaphore, U16 token_count);
extern OS_RESULT os_sem_send (OS_ID semaphore);
extern OS_RESULT os_sem_wait (OS_ID semaphore, U16 timeout);
extern void isr_sem_send (OS_ID semaphore);


/* Mailbox Management */
extern void os_mbx_init (OS_ID mailbox, U16 mbx_size);
extern OS_RESULT os_mbx_send (OS_ID mailbox, void *message_ptr, U16 timeout);
extern OS_RESULT os_mbx_wait (OS_ID mailbox, void  **message, U16 timeout);
extern OS_RESULT os_mbx_check (OS_ID mailbox);
extern void isr_mbx_send (OS_ID mailbox, void *message_ptr);
extern OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message);


/* Mutex Management */
extern void os_mut_init (OS_ID mutex);
extern OS_RESULT os_mut_release (OS_ID mutex);
extern OS_RESULT os_mut_wait (OS_ID mutex, U16 timeout);


/* Time Management */
extern void os_dly_wait (U16 delay_time);
extern void os_itv_set (U16 interval_time);
extern void os_itv_wait (void);


/* User Timer Management */
extern OS_ID os_tmr_create (U16 tcnt, U16 info);
extern OS_ID os_tmr_kill (OS_ID timer);


/* System Functions */
extern void tsk_lock (void);
extern void tsk_unlock (void);


/* Fixed Memory Block Management Functions */
extern int  _init_box  (void *box_mem, U32 box_size, U32 blk_size);
extern void *_alloc_box (void *box_mem)  __swi (6);
extern void *_calloc_box (void *box_mem);
extern int  _free_box (void *box_mem, void *box)  __swi (7);



#ifdef __cplusplus               // EC++
}
#endif


/*----------------------------------------------------------------------------
 * end of file
 *---------------------------------------------------------------------------*/
 
#endif
 
从两个头文件看,当用RV时,估计是无法使用:


/*----------------------------------------------------------------------------
 *                        ARTX Flash File System API
 *---------------------------------------------------------------------------*/


 


/*----------------------------------------------------------------------------
 *                             ARTX TcpNet API
 *---------------------------------------------------------------------------*/


 


 


路过

鸡蛋

鲜花

握手

雷人

发表评论 评论 (1 个评论)

回复 pubstar 2006-4-22 13:35

3.0好像已经可以了