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

📄 example.c

📁 AT91所有开发板的资料 AT91所有开发板的资料
💻 C
字号:
#include "module.h"#include "swis.h"extern ARMWord Image$$RO$$Base[];extern ARMWord Image$$RO$$Limit[];extern ARMWord Image$$RW$$Base[];extern ARMWord Image$$ZI$$Base[];extern ARMWord Image$$ZI$$Limit[];extern void start(char *cmd);extern ModuleHandle init(void);extern void final(void);extern ServiceBlock service(ServiceBlock sb);extern CallBack swi(unsigned swino, SWIRegs *regs);extern CallBack command(char *cmd);static const CmdTable Example_Commands[] = {    {	"ExCommand",	command,	0,	"Usage: ExCommand <arguments>",	"A trivial command example"    },    {	0, 0, 0, 0, 0    }};static const ModuleHeader Example_Header = {	MODULE_MAGIC,		/* magic field */	0,			/* Autoboot this module */	MAJOR_VERSION,		/* major version = current version */	MINOR_VERSION,		/* minor version = current version */	0,			/* checksum - done later - set to 0 now */        Image$$RO$$Base,	/* ro_base */        Image$$RO$$Limit,	/* ro_limit */        Image$$RW$$Base,	/* rw_base */        Image$$ZI$$Base,	/* zi_base */        Image$$ZI$$Limit,	/* zi_limit */        &Example_Header,	/* 'self' */	start,			/* Example boot entry */	init,			/* No init code */	final,			/* No final code */	service,		/* No service code */	"Example",		/* title */	"Example         1.23 (12 MAY 1998)",	/* help string */	Example_Commands,	0x100,	swi};__global_reg(6) unsigned R9;extern __swi(SWI_PrettyPrint) void PrettyPrint(const char *fmt, ...);extern __swi(SWI_CLI) void CLI(char *cmd);extern __swi(SWI_Exit) void Exit(void);extern __swi(0x100) MySWI(int r0);void start(char *cmd){    unsigned r0;    PrettyPrint("*** In start entry, R0 = %s, R9 = %x", cmd, R9);    PrettyPrint("*** Calling my own SWI (0x100) with R0 = 0x12341234");    r0 = MySWI(0x12341234);    PrettyPrint("*** My SWI returned %x", r0);    PrettyPrint("*** Executing my own command \"ExCommand Hello, World\"");    CLI("ExCommand Hello, World");    Exit();}ModuleHandle init(void){    PrettyPrint("*** In init entry, returning R0 = 0x12345678");    return (ModuleHandle)0x12345678;}void final(void){    PrettyPrint("*** In final entry, R9 = %x", R9);}__value_in_regs ServiceBlock service(ServiceBlock sb){    PrettyPrint("*** In service entry, R0 = %d, R1 = %x, R2 = %x", sb.r0, sb.r1, sb.r2);    PrettyPrint("*** ... R3 = %x, R9 = %x", sb.r3, R9);    sb.r0 = 0;    return sb;}CallBack command(char *cmd){    PrettyPrint("*** In command handler, R0 = %s, R9 = %x", cmd, R9);    return 0;}CallBack swi(unsigned swino, SWIRegs *regs){    PrettyPrint("*** In swi handler, SWI #%d, regs->r[0] = %x, R9 = %x", swino, regs->r[0], R9);    PrettyPrint("*** Returning R0 = 0xABCDABCD");    regs->r[0] = 0xABCDABCD;    return 0;}

⌨️ 快捷键说明

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