织梦CMS - 轻松建站从此开始!

罗索

semihosting of ARM

落鹤生 发布于 2010-05-13 21:03 点击:次 
最近想编写一个自动烧写到片外Flash的Bootloader(我用的是周立功的EasyARM2200开发板),在看ADS的开发文档时,经常出现semihosting这个术语,大概查找了一下,是有关调试的一种方法。
TAG:

最近想编写一个自动烧写到片外Flash的Bootloader(我用的是周立功的EasyARM2200开发板),在看ADS的开发文档时,经常出现semihosting这个术语,大概查找了一下,是有关调试的一种方法。我对调试方法还是很感兴趣的,因为笔记本没有并口,用不了EasyJTAG仿真器,一直都是用串口直接烧到片内Flash中跑程序的。
 
介绍一下semihosting的功能:
Semihosting is a mechanism for ARM targets to communicate input/output requests
from application code to a host computer running a debugger. This mechanism could be
used, for example, to allow functions in the C library, such as printf() and scanf(), to use the screen and keyboard of the host rather than having a screen and keyboard on the target system.
  This is useful because development hardware often does not have all the input and
output facilities of the final system. Semihosting allows the host computer to provide these facilities.
  Semihosting is implemented by a set of defined software interrupt (SWI) operations.
The application invokes the appropriate SWI and the debug agent then handles the SWI
exception. The debug agent provides the required communication with the host.
  In many cases, the semihosting SWI will be invoked by code within library functions. The application can also invoke the semihosting SWI directly. Refer to the C library descriptions in the ADS Compilers and Libraries Guide for more information on support for semihosting in the ARM C library.
 
  下面列出部分semihosted operations
SYS_OPEN (0x01)  Open a file on the host
SYS_CLOSE (0x02)  Close a file on the host
SYS_WRITEC (0x03)  Write a character to the console
SYS_WRITE (0x05)  Write to a file on the host
SYS_READ (0x06)  Read the contents of a file into a buffer
SYS_ISERROR (0x08) Determine if a return code is an error
SYS_ISTTY (0x09) Check whether a file is connected to an interactive device
SYS_SEEK (0x0A)  Seek to a position in a file
SYS_FLEN (0x0C)  Return the length of a file
SYS_TMPNAM (0x0D)  Return a temporary name for a file
SYS_REMOVE (0x0E)  Remove a file from the host
SYS_RENAME (0x0F)  Rename a file on the host
SYS_CLOCK (0x10)  Number of centiseconds since execution started
SYS_SYSTEM (0x12)  Pass a command to the host command-line interpreter
SYS_ERRNO (0x13)  Get the value of the C library errno variable

  总结一下,semihosting是在调试器里使用,一旦程序使用semihosting,则代码(库函数)直接产生软件中断,调用主机上的函数,用于对主机的操作。例如:程序中可以使用printf()函数,当执行该函数时,代码产生软件中断,调试器捕捉到该特定中断后,调用主机上的函数执行,最后在调试软件的界面中显示该函数的结果。换句话说,semihosting提供了与主机的交互功能,方便调试。直接烧到板子里是用不了的,因为没法与主机通信了。
  由于我用不了仿真器,对semihosting的认识只是在理论上的,欢迎与我讨论。
(秩名)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/201005/9404.html]
本文出处:ChinaUnix博客 作者:秩名
顶一下
(1)
100%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容