한국어
Linux Programming
 

유저 공간으로부터 커널로 데이터 복사 / 유저 공간으로 커널 데이터 복사

copy_from_user()

copy_to_user()

 

플랫폼드라이버 등록 및 해제 함수; /include/linux/platform_device.h

platform_register_drivers()

platform_driver_register()

platform_driver_unregister()

 

플랫폼 디바이스 등록 및 해제

platform_device_register()

platform_device_register_simple()

platform_device_unregister()

 

플랫폼디바이스추가

platform_add_devices()

 

버스 드라이버 등록 및 해제; /drivers/base/bus.c, include/linux/device.h

bus_register()

bus_unregister()

 

리소스 관리용 kzalloc(). devm_kzalloc()을 사용하여 할당 된 메모리는 드라이버 분리시 자동으로 해제.

devm_kzalloc(&pdev->dev, sizeof(struct imx_fb_videomode), GFP_KERNEL)

 

물리주소를 가상주소로 매핑. 

void __iomem * ioremap(resource_size_t offset, unsigned long size)

 

I/O 메모리 영역을 확보. 이 영역의 소유주를 표시.

request_mem_region(start,n,name) __request_region(&iomem_resource, (start), (n), (name), 0)

 

디바이스 I/O 레지스터 리소스 가져오기

struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0) 

 

인터럽트(Interrupt) 가져오기

예: 디바이스트리 interrupts 프로퍼티에서

s->irq = platform_get_irq(pdev, 0);

 

플랫폼 드라이버 데이터(정보)를 등록

platform_set_drvdata(struct platform_device *pdev, void *data)

 

리소스 체크, memory region (request_mem_region), ioremaps(ioremap) 을 한번에 수행.

devm_ioremap_resource()

 

플랫폼 디바이스 데이터 포인터 반환

void *dev_get_platdata(const struct device *dev)

 

 

접두사 of (Open Firmware)가 붙여진 API

 

각 유형별 프로퍼티를 얻기위한 API

of_property_read_string()

of_property_read_u32()

of_property_read_bool()

 

Custom 프로퍼티 가져오기

of_get_property()

 

예:

static int imx_uart_probe(struct platform_device *pdev)
{
    struct device_node *np = pdev->dev.of_node;
    if (of_get_property(np, "rts-gpios", NULL))
	 ...
}

 

호환가능한 머신 테스트

of_machine_is_compatible("fsl,imx28-evk")

 

디바이스가 of_device_id 목록의 항목과 일치하는지 확인;

시스템에 존재하는 platform_device 가 지원되는 장치 목록(matches)에 있는지 확인하기 위해 드라이버가 사용한다.

const struct of_device_id *of_match_device(const struct of_device_id *matches, const struct device *dev)

 

 

매크로

 

드라이버 함수 심볼릭 내보내기 (외부에서 호출 가능하도록)

EXPORT_SYMBOL_GPL()

 

구조체(type)에 속한 멤버(member)의 포인터(ptr)를 구조체 포인터로 캐스트

container_of(ptr, type, member)

 

번호 제목 글쓴이 날짜 조회 수
44 리눅스 Qt 응용프로그램 AppImage 로 구축 makersweb 2024.01.07 450
43 GRUB의 timeout 설정 makersweb 2023.11.07 431
42 lubuntu 22.04 LTS 설치 file makersweb 2023.01.23 1231
41 시스템에서 사용 가능한 D-Bus 서비스를 보려면? makersweb 2022.12.29 1119
40 리눅스에서 네트워크 구성 makersweb 2022.06.11 2802
39 D-Bus ObjectManager file makersweb 2022.02.12 570
38 ifconfig 는 대부분 ip 명령으로 대체 makersweb 2022.02.12 1218
37 SocketCAN 유틸 사용방법 file makersweb 2022.02.05 6873
36 dbus-broker를 기본 DBus 구현으로 설정 makersweb 2021.01.20 1142
35 리눅스 오디오 스택과 아키텍처 file makersweb 2020.09.02 2827
34 wayland-scanner 를 통해 Wayland 프로토콜 코드생성 makersweb 2020.06.08 880
33 Wayland 의 Client Application 프로그래밍 기본 루틴 makersweb 2020.06.04 1591
32 Wayland 의 주요 객체들 makersweb 2020.06.04 842
31 Weston 의 설명 및 관련 컴포넌트 makersweb 2020.06.03 2425
30 64비트 리눅스에서 32비트 응용프로그램을 실행하려면 makersweb 2020.02.29 1731
29 initramfs (initial ram file system: 초기 램 파일 시스템) makersweb 2020.02.25 1980
» 플랫폼 디바이스 드라이버 개발 시 많이 사용되는 커널 API 및 매크로 makersweb 2020.01.28 4683
27 PATH에 새로운 경로 추가 makersweb 2019.09.19 386
26 리눅스 컴파일러 최신으로 업데이트 linux 2018.12.26 1888
25 libblkid - USB Storage의 정보 가져오기 makersweb 2018.10.18 661