include/proto.h

本文档详细介绍了嵌入式系统中常用的核心函数及其功能,包括字符串操作、中断管理、进程调度等关键模块,为嵌入式软件开发提供实用指南。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Code:
  1. /*  
  2.     By Marcus Xing  
  3.     include/proto.h  
  4.     原型集合  
  5. */  
  6.   
  7. /*  
  8.     forward include:  
  9.     type.h  
  10.     console.h  
  11.     tty.h  
  12.     protect.h  
  13.     proc.h  
  14.     ipc.h  
  15. */  
  16.   
  17. #ifndef _PROTO_H_   
  18. #define _PROTO_H_   
  19.        
  20.     /* 打印一个字符串 */  
  21.     void Disp_Str(u8 *psz_Str);   
  22.        
  23.     /* 打印一个带颜色的字符串 */  
  24.     void Disp_Color_Str(u8 *psz_Str,u8 color);   
  25.        
  26.     /*   
  27.         此函数以16进制打印一个32位的整数,  
  28.         不考虑无符号,前面的0不打印  
  29.     */  
  30.     void Disp_Int(int num);   
  31.        
  32.     /* 写一个值到端口中 */  
  33.     void Out_Byte(u16 port,u8 value);   
  34.        
  35.     /* 从端口读一个值并返回 */  
  36.     u8   In_Byte(u16 port);   
  37.        
  38.     /* 此函数用于填充GDT或IDT中的描述符 */  
  39.     void Fill_Desc(u8 desc_no,u32 base,u32 limit,u16 attr);   
  40.        
  41.     /* 此函数用于填充一个IDT中的门描述符 */  
  42.     void Fill_Gate(u8 idt_no,Int_Handler handler,u8 type,u8 privilege);   
  43.        
  44.     /* 粗糙的延迟函数 */  
  45.     void Delay(u32 time);   
  46.        
  47.     /* 按字节复制函数 */  
  48.     void Memory_Copy(void *dest,void *src,int len);   
  49.        
  50.     /* 进程A的执行体 */  
  51.     void Proc_A();   
  52.        
  53.     /* 进程B的执行体 */  
  54.     void Proc_B();   
  55.        
  56.     /* 进程C的执行体 */  
  57.     void Proc_C();   
  58.        
  59.     /* 激活vec_no号中断 */  
  60.     void Enable_IRQ(int vec_no);   
  61.        
  62.     /* 屏蔽vec_no号中断 */  
  63.     void Disable_IRQ(int vec_no);   
  64.        
  65.     /* 时钟中断的处理函数 */  
  66.     void Clock_Handler(int vec_no);   
  67.        
  68.     /* 其他没特点的外中断处理函数 */  
  69.     void Hard_Int_Handler(int hw_vec_no);   
  70.        
  71.     /* 精确到10ms的延迟函数,形参的单位是毫秒 */  
  72.     void Milli_Delay(int delay_time_by_milli);   
  73.        
  74.     /* 进程调度 */  
  75.     void Schedule();   
  76.        
  77.     /* 简单的开中断 */  
  78.     void Enable_Int();   
  79.        
  80.     /* 简单的关中断 */  
  81.     void Disable_Int();   
  82.        
  83.     /* 终端进程的执行体 */  
  84.     void Proc_TTY();   
  85.        
  86.     /* 模仿printf */  
  87.     int Printf(const char *fmt,...);   
  88.        
  89.     /* 字符串拷贝 */  
  90.     void Str_Cpy(char *dest,const char *src);   
  91.        
  92.     /* 求字符串长度 */  
  93.     int Str_Len(const char *sz_str);   
  94.        
  95.     /* 以下与TTY和控制台有关 */  
  96.        
  97.     /* 读键盘函数 */  
  98.     void Keyboard_Read(TTY *tty);   
  99.        
  100.     /* 处理键盘输入的函数 */  
  101.     void In_Process(TTY *tty,u32 key);   
  102.        
  103.     /* 根据前景色和背景色产生一个颜色值供Disp_Color_Str使用 */  
  104.     u8  Make_Color(u8 forward_color,u8 back_color);   
  105.        
  106.     /* 判断是否是当前控制台 */  
  107.     int Is_Current_Console(Console *console);   
  108.        
  109.     /* console.c中定义,显示字符 */  
  110.     void Out_Char(Console *console,char c);   
  111.        
  112.     /* 选择控置台 */  
  113.     void Select_Console(int console_no);   
  114.        
  115.     /* 控制台滚动 */  
  116.     void Scroll_Screen(Console *con,int direction);   
  117.        
  118.     /* 以下函数跟IPC有关 */  
  119.        
  120.     /* 收发消息的接口函数 */  
  121.     void Send_Receive_Shell(int function,int send_recev_pid,Message *m);   
  122.        
  123.     /* 判断是否发送进程是否产生死锁 */  
  124.     void Is_Dead_Lock(int src_pid,int dest_pid);   
  125.        
  126.     /* 发送消息 */  
  127.     void MSG_Send(int receive_pid,Message *m,PCB *caller);   
  128.        
  129.     /* 接收消息 */  
  130.     void MSG_Receive(int send_pid,Message *m,PCB *caller);   
  131.        
  132.     /* 收发消息的执行体 */  
  133.     void Proc_Send_Receive();   
  134.   
  135.     /* 断言功能函数 */  
  136.     void Assert_Failure(char *file,char *base_file,int line);   
  137.        
  138.     /* 使用断言的宏 */  
  139.     #define Assert(exp) /   
  140.         if(exp);          /   
  141.         else              /   
  142.         {                 /   
  143.             Assert_Failure(__FILE__,__BASE_FILE__,__LINE__); /   
  144.         }   
  145.        
  146.     /* PANIC功能函数 */  
  147.     void Panic(char *buf,...);   
  148.        
  149.     /* 得到当前的ticks值 */  
  150.     int Get_Ticks();   
  151.        
  152.     /* 以下是系统调用相关 */  
  153.     /* 系统调用接口 */  
  154.     void Write(const char *buf);   
  155.     void System_Call_Write(int unused1,int unused2,const char *buf,PCB *pcb);   
  156.     void Send_Receive(int function,int send_recev_pid,Message *m);   
  157.     void System_Call_Send_Receive(int function,int send_recev_pid,Message *m,PCB *caller);   
  158.        
  159.     /* 回到实模式 */  
  160.     void Prepare_To_Real_Mode();   
  161.        
  162.     /* 重启函数的接口 */  
  163.     void Reset();   
  164.                    
  165.     /* 所有系统调用统一入口 */  
  166.     void System_Call();        
  167.   
  168. #endif   

 

make -C …/…/ /root/bpf/linux-4.19.90/samples/bpf/ BPF_SAMPLES_PATH=/root/bpf/linux-4.19.90/samples/bpf make[1]: Entering directory ‘/root/bpf/linux-4.19.90’ CALL scripts/checksyscalls.sh DESCEND objtool make -C /root/bpf/linux-4.19.90/samples/bpf/…/…/tools/lib/bpf/ RM=‘rm -rf’ LDFLAGS= srctree=/root/bpf/linux-4.19.90/samples/bpf/…/…/ O= Warning: Kernel ABI header at ‘tools/include/uapi/linux/bpf.h’ differs from latest version at ‘include/uapi/linux/bpf.h’ CLANG-bpf /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.o In file included from /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:4: In file included from ./include/linux/tcp.h:24: ./include/net/inet_connection_sock.h:214:3: error: use of undeclared identifier ‘KBUILD_MODNAME’ pr_debug(“inet_csk BUG: unknown timer value\n”); ^ ./include/linux/printk.h:340:2: note: expanded from macro ‘pr_debug’ dynamic_pr_debug(fmt, ##VA_ARGS) ^ ./include/linux/dynamic_debug.h:125:2: note: expanded from macro ‘dynamic_pr_debug’ DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); ^ ./include/linux/dynamic_debug.h:99:2: note: expanded from macro ‘DEFINE_DYNAMIC_DEBUG_METADATA’ DEFINE_DYNAMIC_DEBUG_METADATA_KEY(name, fmt, .key.dd_key_false, ^ ./include/linux/dynamic_debug.h:77:14: note: expanded from macro ‘DEFINE_DYNAMIC_DEBUG_METADATA_KEY’ .modname = KBUILD_MODNAME, ^ In file included from /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:4: In file included from ./include/linux/tcp.h:24: ./include/net/inet_connection_sock.h:228:3: error: use of undeclared identifier ‘KBUILD_MODNAME’ pr_debug(“reset_xmit_timer: sk=%p %d when=0x%lx, caller=%p\n”, ^ ./include/linux/printk.h:340:2: note: expanded from macro ‘pr_debug’ dynamic_pr_debug(fmt, ##VA_ARGS) ^ ./include/linux/dynamic_debug.h:125:2: note: expanded from macro ‘dynamic_pr_debug’ DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); ^ ./include/linux/dynamic_debug.h:99:2: note: expanded from macro ‘DEFINE_DYNAMIC_DEBUG_METADATA’ DEFINE_DYNAMIC_DEBUG_METADATA_KEY(name, fmt, .key.dd_key_false, ^ ./include/linux/dynamic_debug.h:77:14: note: expanded from macro ‘DEFINE_DYNAMIC_DEBUG_METADATA_KEY’ .modname = KBUILD_MODNAME, ^ In file included from /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:4: In file included from ./include/linux/tcp.h:24: ./include/net/inet_connection_sock.h:244:3: error: use of undeclared identifier ‘KBUILD_MODNAME’ pr_debug(“inet_csk BUG: unknown timer value\n”); ^ ./include/linux/printk.h:340:2: note: expanded from macro ‘pr_debug’ dynamic_pr_debug(fmt, ##VA_ARGS) ^ ./include/linux/dynamic_debug.h:125:2: note: expanded from macro ‘dynamic_pr_debug’ DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); ^ ./include/linux/dynamic_debug.h:99:2: note: expanded from macro ‘DEFINE_DYNAMIC_DEBUG_METADATA’ DEFINE_DYNAMIC_DEBUG_METADATA_KEY(name, fmt, .key.dd_key_false, ^ ./include/linux/dynamic_debug.h:77:14: note: expanded from macro ‘DEFINE_DYNAMIC_DEBUG_METADATA_KEY’ .modname = KBUILD_MODNAME, ^ 3 errors generated. make[1]: Leaving directory ‘/root/bpf/linux-4.19.90’
最新发布
07-22
编译xdp_redirect.c,20个报错 In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:31:8: error: redefinition of 'in_addr' struct in_addr ^ /usr/include/linux/in.h:89:8: note: previous definition is here struct in_addr { ^ In file included from xdp_redirect.c:8: In file included from /usr/include/netinet/in.h:37: /usr/include/x86_64-linux-gnu/bits/in.h:150:8: error: redefinition of 'ip_mreqn' struct ip_mreqn ^ /usr/include/linux/in.h:180:8: note: previous definition is here struct ip_mreqn { ^ In file included from xdp_redirect.c:8: In file included from /usr/include/netinet/in.h:37: /usr/include/x86_64-linux-gnu/bits/in.h:158:8: error: redefinition of 'in_pktinfo' struct in_pktinfo ^ /usr/include/linux/in.h:251:8: note: previous definition is here struct in_pktinfo { ^ In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:42:5: error: redefinition of enumerator 'IPPROTO_IP' IPPROTO_IP = 0, /* Dummy protocol for TCP. */ ^ /usr/include/linux/in.h:30:21: note: expanded from macro 'IPPROTO_IP' #define IPPROTO_IP IPPROTO_IP ^ /usr/include/linux/in.h:29:3: note: previous definition is here IPPROTO_IP = 0, /* Dummy protocol for TCP */ ^ In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:44:5: error: redefinition of enumerator 'IPPROTO_ICMP' IPPROTO_ICMP = 1, /* Internet Control Message Protocol. */ ^ /usr/include/linux/in.h:32:23: note: expanded from macro 'IPPROTO_ICMP' #define IPPROTO_ICMP IPPROTO_ICMP ^ /usr/include/linux/in.h:31:3: note: previous definition is here IPPROTO_ICMP = 1, /* Internet Control Message Protocol */ ^ In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:46:5: error: redefinition of enumerator 'IPPROTO_IGMP' IPPROTO_IGMP = 2, /* Internet Group Management Protocol. */ ^ /usr/include/linux/in.h:34:23: note: expanded from macro 'IPPROTO_IGMP' #define IPPROTO_IGMP IPPROTO_IGMP ^ /usr/include/linux/in.h:33:3: note: previous definition is here IPPROTO_IGMP = 2, /* Internet Group Management Protocol */ ^ In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:48:5: error: redefinition of enumerator 'IPPROTO_IPIP' IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94). */ ^ /usr/include/linux/in.h:36:23: note: expanded from macro 'IPPROTO_IPIP' #define IPPROTO_IPIP IPPROTO_IPIP ^ /usr/include/linux/in.h:35:3: note: previous definition is here IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94) */ ^ In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:50:5: error: redefinition of enumerator 'IPPROTO_TCP' IPPROTO_TCP = 6, /* Transmission Control Protocol. */ ^ /usr/include/linux/in.h:38:22: note: expanded from macro 'IPPROTO_TCP' #define IPPROTO_TCP IPPROTO_TCP ^ /usr/include/linux/in.h:37:3: note: previous definition is here IPPROTO_TCP = 6, /* Transmission Control Protocol */ ^ In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:52:5: error: redefinition of enumerator 'IPPROTO_EGP' IPPROTO_EGP = 8, /* Exterior Gateway Protocol. */ ^ /usr/include/linux/in.h:40:22: note: expanded from macro 'IPPROTO_EGP' #define IPPROTO_EGP IPPROTO_EGP ^ /usr/include/linux/in.h:39:3: note: previous definition is here IPPROTO_EGP = 8, /* Exterior Gateway Protocol */ ^ In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:54:5: error: redefinition of enumerator 'IPPROTO_PUP' IPPROTO_PUP = 12, /* PUP protocol. */ ^ /usr/include/linux/in.h:42:22: note: expanded from macro 'IPPROTO_PUP' #define IPPROTO_PUP IPPROTO_PUP ^ /usr/include/linux/in.h:41:3: note: previous definition is here IPPROTO_PUP = 12, /* PUP protocol */ ^ In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:56:5: error: redefinition of enumerator 'IPPROTO_UDP' IPPROTO_UDP = 17, /* User Datagram Protocol. */ ^ /usr/include/linux/in.h:44:22: note: expanded from macro 'IPPROTO_UDP' #define IPPROTO_UDP IPPROTO_UDP ^ /usr/include/linux/in.h:43:3: note: previous definition is here IPPROTO_UDP = 17, /* User Datagram Protocol */ ^ In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:58:5: error: redefinition of enumerator 'IPPROTO_IDP' IPPROTO_IDP = 22, /* XNS IDP protocol. */ ^ /usr/include/linux/in.h:46:22: note: expanded from macro 'IPPROTO_IDP' #define IPPROTO_IDP IPPROTO_IDP ^ /usr/include/linux/in.h:45:3: note: previous definition is here IPPROTO_IDP = 22, /* XNS IDP protocol */ ^ In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:60:5: error: redefinition of enumerator 'IPPROTO_TP' IPPROTO_TP = 29, /* SO Transport Protocol Class 4. */ ^ /usr/include/linux/in.h:48:21: note: expanded from macro 'IPPROTO_TP' #define IPPROTO_TP IPPROTO_TP ^ /usr/include/linux/in.h:47:3: note: previous definition is here IPPROTO_TP = 29, /* SO Transport Protocol Class 4 */ ^ In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:62:5: error: redefinition of enumerator 'IPPROTO_DCCP' IPPROTO_DCCP = 33, /* Datagram Congestion Control Protocol. */ ^ /usr/include/linux/in.h:50:23: note: expanded from macro 'IPPROTO_DCCP' #define IPPROTO_DCCP IPPROTO_DCCP ^ /usr/include/linux/in.h:49:3: note: previous definition is here IPPROTO_DCCP = 33, /* Datagram Congestion Control Protocol */ ^ In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:64:5: error: redefinition of enumerator 'IPPROTO_IPV6' IPPROTO_IPV6 = 41, /* IPv6 header. */ ^ /usr/include/linux/in.h:52:23: note: expanded from macro 'IPPROTO_IPV6' #define IPPROTO_IPV6 IPPROTO_IPV6 ^ /usr/include/linux/in.h:51:3: note: previous definition is here IPPROTO_IPV6 = 41, /* IPv6-in-IPv4 tunnelling */ ^ In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:66:5: error: redefinition of enumerator 'IPPROTO_RSVP' IPPROTO_RSVP = 46, /* Reservation Protocol. */ ^ /usr/include/linux/in.h:54:23: note: expanded from macro 'IPPROTO_RSVP' #define IPPROTO_RSVP IPPROTO_RSVP ^ /usr/include/linux/in.h:53:3: note: previous definition is here IPPROTO_RSVP = 46, /* RSVP Protocol */ ^ In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:68:5: error: redefinition of enumerator 'IPPROTO_GRE' IPPROTO_GRE = 47, /* General Routing Encapsulation. */ ^ /usr/include/linux/in.h:56:22: note: expanded from macro 'IPPROTO_GRE' #define IPPROTO_GRE IPPROTO_GRE ^ /usr/include/linux/in.h:55:3: note: previous definition is here IPPROTO_GRE = 47, /* Cisco GRE tunnels (rfc 1701,1702) */ ^ In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:70:5: error: redefinition of enumerator 'IPPROTO_ESP' IPPROTO_ESP = 50, /* encapsulating security payload. */ ^ /usr/include/linux/in.h:58:22: note: expanded from macro 'IPPROTO_ESP' #define IPPROTO_ESP IPPROTO_ESP ^ /usr/include/linux/in.h:57:3: note: previous definition is here IPPROTO_ESP = 50, /* Encapsulation Security Payload protocol */ ^ In file included from xdp_redirect.c:8: /usr/include/netinet/in.h:72:5: error: redefinition of enumerator 'IPPROTO_AH' IPPROTO_AH = 51, /* authentication header. */ ^ /usr/include/linux/in.h:60:21: note: expanded from macro 'IPPROTO_AH' #define IPPROTO_AH IPPROTO_AH ^ /usr/include/linux/in.h:59:3: note: previous definition is here IPPROTO_AH = 51, /* Authentication Header protocol */ ^ fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated.
06-18
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值