Nios II ソフトウェア開発ハンドブック Version 1.2 第5章. HAL用デバイス・ドライバの開発 ver.1.1

Similar documents
Nios II ソフトウェア開発ハンドブック Version 1.2 セクション IV. 付録 

Nios II ソフトウェア開発ハンドブック Version 1.2 第4章. HALを使用したプログラムの開発 ver.1.2

Nios® II HAL API を使用したソフトウェア・サンプル集 「Modular Scatter-Gather DMA Core」

Nios II IDE によるソフトウェア開発 - セクション 1

Nios II ソフトウェア開発ハンドブック Version 1.2 第6章. 例外処理 ver.1.2

FreeBSD 1

Nios II ハードウェア・チュートリアル

1) // 2) I/O 3) Japan Advanced Institute of Science and Technology 2013/07/26 1

IP L09( Tue) : Time-stamp: Tue 14:52 JST hig TCP/IP. IP,,,. ( ) L09 IP (2017) 1 / 28

Nios II 簡易チュートリアル

program.dvi

プロセッサ・アーキテクチャ

double float

Linuxデバイスドライバ.PDF

Makefile, TCPソケットサーバ, コマンドライン引数

エラー処理・分割コンパイル・コマンドライン引数

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() malloc 2 #include <stdio.h> #include

Nios II - Vectored Interrupt Controller の実装

Lab GPIO_35 GPIO

Nios II IDE によるソフトウェア開発 セクション 2

: Nonblocking I/O readpartial read EOF Solaris FILE 256 ungetc SEGV errno stdio considered harmful p.


Nios IIプロセッサ・リファレンス・ハンドブック、セクション I. Nios IIプロセッサ Ver. 1.2

mbed_library_study_meeting_v1.0.key

thesis.dvi

r07.dvi

ohp07.dvi

Nios II カスタム・インストラクションによるキャスト(型変換)の高速化

tutorial_lc.dvi

Avalon Memory-Mappedブリッジ

I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) + x * x + x x (4) * *

新・明解C言語 ポインタ完全攻略

untitled

複数の Nios II を構成する際の注意事項

DA100データアクイジションユニット通信インタフェースユーザーズマニュアル

MINI2440マニュアル

II ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D

44 6 MPI 4 : #LIB=-lmpich -lm 5 : LIB=-lmpi -lm 7 : mpi1: mpi1.c 8 : $(CC) -o mpi1 mpi1.c $(LIB) 9 : 10 : clean: 11 : -$(DEL) mpi1 make mpi1 1 % mpiru

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1

Nios II Flash Programmer ユーザ・ガイド

Linux on ITRON-ハイブリッド構造の実装

matrox0

1.ppt

VISPO /表1-4

mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( )

第3章 OpenGL の基礎

pgen :: net_stream net (" eth0 ", pgen :: open_mode :: netif ); uint8_t buf [10000]; size_t recvlen = net. recv (buf, sizeof buf ); pgen :: udp pack (

1. 入力した正の整数を降順に並べ換えて出力するプログラムを作成せよ プログラムは個別にコンパイルし make コマンドで実行すること 入力データは 50 以下とし 以下の数が混在しているとする 16 進数 : 先頭 1 文字が x または X( エックスの小文字か大文字 ) 8 進数 : 先頭 1

:30 12:00 I. I VI II. III. IV. a d V. VI

DPD Software Development Products Overview

【注意事項】RXファミリ 組み込み用TCP/IP M3S-T4-Tiny

ファイル入出力と プロセス間通信 \(1\)

file"a" file"b" fp = fopen("a", "r"); while(fgets(line, BUFSIZ, fp)) {... fclose(fp); fp = fopen("b", "r"); while(fgets(line, BUFSIZ, fp)) {... fclose

J.JSSAC Vol. 7, No. 2, Mathematica Maple,., Open asir Open xxx asir. Open xxx Open asir, asir., Open xxx, Linux Open asir Open sm1 (kan/sm1). C

第3章 OpenGL の基礎

SOPC Builder ペリフェラル 簡易ユーザ・ガイド - PIO (Parallel I/O)

r08.dvi

void hash1_init(int *array) int i; for (i = 0; i < HASHSIZE; i++) array[i] = EMPTY; /* i EMPTY */ void hash1_insert(int *array, int n) if (n < 0 n >=

bitvisor-ipc v12b.key

CM-3G 周辺モジュール拡張技術文書 MS5607センサ(温度、気圧)

QW-3414

01_06.indd


昨年度までの研究紹介 および 研究計画

3.1 stdio.h iostream List.2 using namespace std C printf ( ) %d %f %s %d C++ cout cout List.2 Hello World! cout << float a = 1.2f; int b = 3; cout <<

output2010本文.indd

ikuo/enshu/keisanki/ GUI(Graphica

Microsoft Word - ALT0982_program_epcs_by_niosii_v10.doc

r03.dvi

17 1. strucr Potter ( ) Harry Potter and the Philosopher s Stone 1997 English Title : Harry Potter and the Philosopher s Stone : : 1997 #include<stdio

yacc.dvi

C言語によるアルゴリズムとデータ構造

Transcription:

5. HAL NII52005-1.1 HAL Hardware Abstraction Layer HAL API Application Programming Interface Nios II 2 HAL HAL API API HAL API HAL API DMA HAL HAL API HAL API ASCII LCD printf() LCD Altera Corporation 5 1 2004 12 Preliminary

API HAL API HAL API HAL API HAL API HAL C API HAL API 5 17 HAL HAL API API C++ HAL HAL C++ C C HAL C 4 1 HAL HAL 1. 2. 3. main () 4. HAL 5. HAL 5 2 Altera Corporation Nios II 2004 12

HAL SOPC Builder SOPC Builder Nios II SOPC Builder system.h SOPC Builder system.h Nios II system.h Nios II SOPC Builder SOPC Builder Nios II system.h SOPC Builder system.h 4 1 HAL SOPC Builder system.h SOPC Builder system.h SOPC Builder SOPC Builder Nios II SOPC Builder SOPC Builder Altera Corporation 5 3 2004 12 Nios II

SOPC Builder Nios II <Nios II >/components < >_regs.h inc JTAG UART <Nios II >/components/altera_avalon_jtag_uart/ inc/altera_avalon_jtag_uart_regs.h _regs.h IORD_< >_< > IOWR_< >_< > 7 1 < >_ < >_< >_MSK < >_< >_< >_OFST PE ALTERA_AVALON_UART_STATUS_PE_MSK ALTERA_AVALON_UART_STATUS_PE_OFST _regs.h _regs.h 5 4 Altera Corporation Nios II 2004 12

HAL 7 1 _regs.h SOPC Builder HAL HAL 3 1 HAL HAL HAL API DMA HAL alt_dev alt_dev typedef struct { alt_llist llist; /* */ const char* name; int (*open) (alt_fd* fd, const char* name, int flags, int mode); int (*close) (alt_fd* fd); int (*read) (alt_fd* fd, char* ptr, int len); int (*write) (alt_fd* fd, const char* ptr, int len); Altera Corporation 5 5 2004 12 Nios II

HAL int (*lseek) (alt_fd* fd, int ptr, int dir); int (*fstat) (alt_fd* fd, struct stat* buf); int (*ioctl) (alt_fd* fd, int req, void* arg); } alt_dev; HAL open() open() open() close() read() write() lseek() fstat() ioctl() 10 1 HAL API errno errno.h ioctl() errno ENOTTY ENOTTY errno HAL int alt_fd* alt_fd open() alt_fd typedef struct { alt_dev* dev; void* priv; int fd_flags; } alt_fd; dev fd_flags open() flags priv HAL 5 6 Altera Corporation Nios II 2004 12

HAL priv alt_dev NULL 5 1 5 1. alt_dev open close read write lseek fstat ioctl TIOCEXCL ioctl() open() close() read() write() lseek() ioctl() alt_dev llist name 2 llist ALT_LLIST_ENTRY name HAL system.h alt_dev HAL int alt_dev_reg (alt_dev* dev) Altera Corporation 5 7 2004 12 Nios II

HAL HAL API ANSI C (4 1 HAL )alt_dev HAL alt_dev 5 5 name read() write() fstat() int alt_fs_reg (alt_dev* dev) HAL HAL API ANSI C (4 1 HAL )alt_dev name 5 8 Altera Corporation Nios II 2004 12

HAL 4 1 HAL 1 1 ISR void alt_tick (void) alt_tick() int alt_sysclk_init (alt_u32 nticks) nticks 1 6 1 alt_timestamp_start() alt_timestamp() alt_timestamp_freq() 3 1 4 1 HAL 10 1 HAL API Altera Corporation 5 9 2004 12 Nios II

HAL sys/alt_flash_dev.h alt_flash_dev struct alt_flash_dev { alt_llist llist; // const char* name; alt_flash_open open; alt_flash_close close; alt_flash_write write; alt_flash_read read; alt_flash_get_flash_info get_info; alt_flash_erase_block erase_block; alt_flash_write_block write_block; void* base_addr; int length; int number_of_regions; flash_region region_info[alt_max_number_of_flash_regions]; }; llist ALT_LLIST_ENTRY name HAL system.h open write_block 8 API alt_flash_open_dev() alt_flash_close_dev() alt_flash_write() alt_write_flash() alt_read_flash() alt_get_flash_info() alt_erase_flash_block() alt_write_flash_block() 5 10 Altera Corporation Nios II 2004 12

HAL base_addr length number_of_regions region_info flash_region 4 14 CFI 2 alt_flash_dev HAL int alt_flash_device_register( alt_flash_fd* fd) DMA HAL DMA 2 DMA HAL DMA 4 20 DMA DMA sys/alt_dma_dev.h Altera Corporation 5 11 2004 12 Nios II

HAL DMA DMA alt_dma_txchan typedef struct alt_dma_txchan_dev_s alt_dma_txchan_dev; struct alt_dma_txchan_dev_s { alt_llist llist; const char* name; int (*space) (alt_dma_txchan dma); int (*send) (alt_dma_txchan dma, const void* from, alt_u32 len, alt_txchan_done* done, void* handle); int (*ioctl) (alt_dma_txchan dma, int req, void* arg); }; 5 2 5 2. alt_dma_txchan llist name space send ioctl ALT_LLIST_ENTRY alt_dma_txchan_open() name system.h alt_dma_txchan_dev API alt_dma_txchan_send() DMA alt_txchan_send() send() 10 20 alt_dma_txchan_send() I/O sys/alt_dma_dev.h space send ioctl null alt_dma_txchan_ioctl() ENOTTY alt_dma_txchan HAL int alt_dma_txchan_reg (alt_dma_txchan_dev* dev) dev 5 12 Altera Corporation Nios II 2004 12

HAL DMA DMA alt_dma_rxchan typedef alt_dma_rxchan_dev_s alt_dma_rxchan; struct alt_dma_rxchan_dev_s { alt_llist list; const char* name; alt_u32 depth; int (*prepare) (alt_dma_rxchan dma, void* data, alt_u32 len, alt_rxchan_done* done, void* handle); int (*ioctl) (alt_dma_rxchan dma, int req, void* arg); }; 5 3 5 3. alt_dma_rxchan llist name depth prepare ioctl ALT_LLIST_ENTRY alt_dma_rxchan_open() name system.h API alt_dma_rxchan_prepare() DMA alt_dma_rxchan_prepare() prepare() 10 14 alt_dma_rxchan_prepare() I/O sys/alt_dma_dev.h prepare() ioctl null alt_dma_rxchan_ioctl() ENOTTY Altera Corporation 5 13 2004 12 Nios II

HAL alt_dma_rxchan HAL int alt_dma_rxchan_reg (alt_dma_rxchan_dev* dev) dev HAL MicroC/OS-II IP lwip TCP/IP lwip 9 1 Lightweight IP SMSC lan91c111 MAC lwip lwip lwip www.sics.se/~adam/lwip/doc/lwip.pdf lan91c111 src inc <Nios II >/components/altera_avalon_lan91c111/ucosii/ Nios II <lwip >/UCOSII/inc/alt_lwip_dev.h 5 14 Altera Corporation Nios II 2004 12

HAL alt_lwip_dev_list alt_lwip_dev_list typedef struct { alt_llist llist; /* */ alt_lwip_dev dev; } alt_lwip_dev_list; struct alt_lwip_dev { /* netif */ struct netif* netif; const char* name; err_t (*init_routine)(struct netif*); void (*rx_routine)(); }; name system.h lwip netif netif <lwip >/UCOSII/src/downloads/lwip-0.7.2/src/include/lwip netif.h netif MAC IP MAC init_routine() alt_lwip_dev init_routine netif err_t init_routine(struct netif* netif) Altera Corporation 5 15 2004 12 Nios II

HAL init_routine() get_mac_addr() get_ip_addr() MAC IP netif 9 1 Lightweight IP init_routine() output() linkoutput() init_routine() output() link_output() 2 netif link_output() link_output() link_output(struct netif *netif, struct pbuf *p) link_output() IP IP MAC ARP link_output() link_output() output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr) rx_routine() alt_lwip_dev rx_routine TCP/IP IRQ ISR rx_mbox <lwip >/UCOSII/src/alt_lwip_dev.c rx_thread rx_mbox rx_routine() rx_routine() TCP/IP 5 16 Altera Corporation Nios II 2004 12

HAL void rx_func() HAL HAL HAL HAL HAL HAL SOPC Builder 5 3 JTAG UART 5-1 JTAG UART <Nios II >/components 5-1. HAL altera_avalon_jtag_uart HAL HAL HAL inc src inc HAL HAL Altera Corporation 5 17 2004 12 Nios II

HAL HAL alt_sys_init.c HAL alt_sys_init.c alt_sys_init.c HAL alt_sys_init() main() alt_sys_init.c alt_sys_init.c #include "system.h" #include "sys/alt_sys_init.h" /* * */ #include "altera_avalon_timer.h" #include "altera_avalon_uart.h" /* * */ ALTERA_AVALON_UART_INSTANCE( UART1, uart1 ); ALTERA_AVALON_TIMER_INSTANCE( SYSCLK, sysclk ); /* * */ void alt_sys_init( void ) { ALTERA_AVALON_UART_INIT( UART1, uart1 ); ALTERA_AVALON_TIMER_INIT( SYSCLK, sysclk ); } Nios II IDE SOPC Builder alt_sys_init.c Nios II IDE gtf-generate alt_sys_init.c gtf-generate HAL gtf-generate 5 18 Altera Corporation Nios II 2004 12

HAL HAL/inc SOPC Builder JATG UART altera_avalon_jtag_uart/hal/inc/altera_avalon_jtag_uart.h alt_sys_init.c 5 18 alt_sys_init.c /* */ < >_INSTANCE 5 18 alt_sys_init.c /* */ alt_sys_init() < >_INIT 5 18 alt_sys_init.c /* */ *_INSTANCE *_INIT altera_avalon_jtag_uart.h ALTERA_AVALON_JTAG_UART_INSTANCE ALTERA_AVALON_JGAT_UART_INIT *_INSTANCE *_INIT 2 2 SOPC Builder system.h system.h alt_sys_init.c Altera Corporation 5 19 2004 12 Nios II

HAL SOPC Builder HAL/inc/<component_name>.h <COMPONENT_NAME>_INSTANCE <COMPONENT_NAME>_INIT HAL main() 5 18 HAL alt_sys_init.c HAL/src makefile component.mk component.mk JTAG UART makefile component.mk makefile C_LIB_SRCS += altera_avalon_uart.c ASM_LIB_SRCS += INCLUDE_PATH += 5 20 Altera Corporation Nios II 2004 12

HAL Nios II IDE component.mk makefilecomponent.mk make C_LIB_SRCS ASM_LIB_SRCS INCLUDE_PATH 5 4 5 4. component.mk make make C_LIB_SRCS ASM_LIB_SRCS INCLUDE_PATH C C <component>/hal/inc component.mk make 5 22 HAL *_INSTANCE *_INIT HAL/inc HAL/src makefile component.mk HAL/src Altera Corporation 5 21 2004 12 Nios II

HAL ALT_USE_SMALL_DRIVERS C Nios II IDE ALT_USE_SMALL_DRIVERS ALT_USE_SMALL_DRIVERS ALT_USE_SMALL_DRIVERS SOPC Builder SOPC Builder alt_ altera_avalon_jtag_uart altera_avalon_jtag_uart_init() alt_jtag_uart_init() avalon_jtag_uart_init() jtag_uart_init() 5 22 Altera Corporation Nios II 2004 12

HAL SOPC Builder HAL 5 17 HAL Nios II IDE Nios II IDE alt_my_component.h alt_my_component.h C Altera Corporation 5 23 2004 12 Nios II

5 24 Altera Corporation Nios II 2004 12