hardware/arch/semihost.html · hardware/arch/semihost.rst 공식 원문 ↗

Zephyr 3.7.0 · Hardware · Architecture · Semihosting

Semihosting 가이드

Target code가 debugger·emulator를 통해 host file과 I/O를 사용하는 방식을 설명합니다.

Official pathhardware/arch/semihost.html
Source filehardware/arch/semihost.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

큰 dataset을 host file로 읽는 예제와 semihost_exec 저수준 interface를 다룹니다.

Targets

ARM · RISC-V

Host I/O

open · read · close · exec

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 0B34910BAC1879BAB63316DEA5DD6742ADB3AEB2E10FD0E21CC86B4F5C1F6747
.. _semihost_guide:

Semihosting Guide
#################

Overview
********

Semihosting is a mechanism that enables code running on ARM and RISC-V targets
to communicate and use the Input/Output facilities on a host computer that is
running a debugger or emulator.

More complete documentation on the available functionality is available at the
`ARM Github documentation`_.

The RISC-V functionality borrows from the ARM definitions, as described at the
`RISC-V Github documentation`_.

File Operations
***************

Semihosting enables files on the host computer to be opened, read, and modified
by an application. This can be useful when attempting to validate the behaviour
of code across datasets that are larger than what can fit into ROM of an
emulated platform. File paths can be either absolute, or relative to the
directory of the running process.

.. code-block:: c

   const char *path = "./data.bin";
   long file_len, bytes_read, fd;
   uint8_t buffer[16];

   /* Open the data file for reading */
   fd = semihost_open(path, SEMIHOST_OPEN_RB);
   if (fd < 0) {
      return -ENOENT;
   }
   /* Read all data from the file */
   file_len = semihost_flen(fd);
   while(file_len > 0) {
      bytes_read = semihost_read(fd, buffer, MIN(file_len, sizeof(buffer)));
      if (bytes_read < 0) {
         break;
      }
      /* Process read data */
      do_data_processing(buffer, bytes_read);
      /* Update remaining length */
      file_len -= bytes_read;
   }
   /* Close the file */
   semihost_close(fd);

Additional Functionality
########################

Additional functionality is available by running semihosting instructions
directly with :c:func:`semihost_exec` with one of the instructions defined
in :c:enum:`semihost_instr`. For complete documentation on the required
arguments and return codes, see the `ARM Github documentation`_.

API Reference
*************

.. doxygengroup:: semihost

.. _ARM Github documentation: https://github.com/ARM-software/abi-aa/blob/main/semihosting/semihosting.rst
.. _RISC-V Github documentation: https://github.com/riscv/riscv-semihosting-spec/blob/main/riscv-semihosting-spec.adoc

Part 3

한국어 전문 번역

개요

Semihosting은 ARM·RISC-V target에서 실행되는 code가 debugger 또는 emulator를 실행 중인 host computer와 통신하고 host의 입출력 기능을 사용하게 하는 mechanism입니다.

사용 가능한 기능의 전체 설명은 ARM semihosting 문서에 있습니다. RISC-V 기능은 ARM 정의를 차용하며 RISC-V semihosting specification에서 설명합니다.

File operation

애플리케이션은 semihosting을 통해 host computer의 file을 열고 읽고 수정할 수 있습니다. Emulated platform의 ROM에 들어가지 않을 정도로 큰 dataset으로 code 동작을 검증할 때 유용합니다. File path는 absolute path 또는 실행 중인 process directory 기준 relative path를 사용할 수 있습니다.

const char *path = "./data.bin";
long file_len, bytes_read, fd;
uint8_t buffer[16];

/* Open the data file for reading */
fd = semihost_open(path, SEMIHOST_OPEN_RB);
if (fd < 0) {
   return -ENOENT;
}
/* Read all data from the file */
file_len = semihost_flen(fd);
while(file_len > 0) {
   bytes_read = semihost_read(fd, buffer, MIN(file_len, sizeof(buffer)));
   if (bytes_read < 0) {
      break;
   }
   /* Process read data */
   do_data_processing(buffer, bytes_read);
   /* Update remaining length */
   file_len -= bytes_read;
}
/* Close the file */
semihost_close(fd);

추가 기능

semihost_instr에 정의된 instruction 중 하나를 semihost_exec()로 직접 실행하면 추가 기능을 사용할 수 있습니다. 필요한 argument와 return code의 전체 정의는 ARM semihosting 문서를 참고하십시오.

API reference

semihost API group은 host file operation과 raw semihost instruction 실행 interface를 제공합니다.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.