Embedded Linux device driver Embedded Linux Issues for
Embedded Linux와 device driver
Embedded Linux의 필요성 • Issues: for the New O/S – New Applications (Wireless, Internet, Multimedia, …) – New Hardware (new cool CPU, Devices, …) – Total cost: NRE, Unit-base, Support – Just –in-Time Technical Support • Embedded Linux – The most Stable, Secure, Cost-Effective, Full -Featured Operating System ever exist
RTOS, Win. CE, Linux
Embedded system을 위한 GUI • Qt/Embedded (Troll Tech) – Feature-rich GUI – Shared Library : 500 K– 4 M – Compatible: Qt/X, Qt/Windows • X-windows System – FREE ! – Tiny-X Server + X-lib – Qt/X, GTK+, Motif – XIM, Font Server – Compatible: PC Linux
Embedded system을 위한 GUI • Micro-windows – FREE! – 500 KB (per Application) • On-going GPL project – Win 32 like, X-Lib like API – FLTK • Other 3 rd Party GUIs – Non-Window GUI • Eyelet, PEG, …
Linux 커널의 구성 • • • Processes Management Memory Management File system Management Networking Device Control
Makefile CC = gcc INCLUDEDIR = /usr/include CFLAG = -D__KERNEL__ -DMODULE –O –Wall –I$(INCLUDEDIR) OBJS = sample. o all : $(OBJS) clean : rm –f *. o *~ core
문자 디바이스 드라이버 • 파일 연산 – Linux에서 각각의 디바이스는 파일 형태로 존재 – 커널은 파일 연산을 이용 I/O 연산을 수행 – <linux/fs. h>에 정의되어 있는 file_operations 구조체를 이용 struct file_operations sample_fops = { read : sample_read, write : sample_write, open : sample_open, release : sample_release, };
문자 디바이스 드라이버 • read/write 연산 – <asm/uaccess. h>에 정의된 함수를 이용 • unsigned long copy_from_user(void *to, const void *from, unsigned long len); • unsigned long copy_to_user(void *to, const void *from, unsigned long len); • void get_user(dataum, ptr); • void put_user(dataum, ptr); – 블러킹 I/O 고려
인터럽트 처리 • 드라이버는 필요 시 커널에게 IRQ를 요구 • 사용 후 반납 • /proc/interrupts 파일에서 IRQ값과 연결된 디바이 스 종류를 확인 • 사용되는 함수 – Int request_irq(unsigned int irq, void (*handler) (int, void *, struct pt_regs *), unsinged long flags, const char *device, void *dev_id); – Void free_irq(unsigned int irq, void *dev_id); • 처리 함수의 등록은 드라이버의 open() 안에서 • 처리 함수의 제거는 release() 안에서
블러킹 I/O • 대기 큐 – struct wait_queue * 변수를 선언 – 프로세스를 sleep 상태로 만들 수 있는 각 사건마다 위 의 포인터 변수가 필요 – 위 포인터 변수를 여러 sleep_on과 wake_up 함수의 인 자로 전달 • 프로세스를 sleep 상태로 만드는 함수 – void interruptible_sleep_on(struct wait_queue **q); – viod sleep_on(struct wait_queue **q); • 프로세스를 깨우는 함수 – void wake_up_interruptible(struct wait_queue **q); – void wake_up(struct wait_queue **q);
RTOS의 예 • • • Chorus Chimera HLinda RT Mach QNX • • p. SOSystem Virtuoso Nucleus vx. Works
- Slides: 44