Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 937 Bytes

semihosting.md

File metadata and controls

38 lines (28 loc) · 937 Bytes
sort
7

Semihosting as an additional debug mechanism

QEMU implements some semihosted operations which can be triggered from the app. For instance, messages can be printed to stderr with the following code:

SYS_WRITE0

void debug_write(char *buf)
{
  asm volatile (
     "movs r0, #0x04\n"
     "movs r1, %0\n"
     "svc      0xab\n"
     :: "r"(buf) : "r0", "r1"
  );
}

The operation number must be passed in r0 (here SYS_WRITE0 operation is defined to 0x04) and arguments are in r1, r2 and r3.

Usage:

debug_write("magic!\n");

References