유저 공간으로부터 커널로 데이터 복사 / 유저 공간으로 커널 데이터 복사
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)
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
45 | [IPC]D-Bus 소개 | makersweb | 2015.02.28 | 29805 |
44 | mmap() 함수, munmap() 함수 | pjk | 2014.02.05 | 15608 |
43 | ioctl() 함수 | makersweb | 2014.02.27 | 14173 |
42 | read() 함수, write() 함수 | makersweb | 2014.03.04 | 11354 |
41 | SocketCAN 유틸 사용방법 | makersweb | 2022.02.05 | 7693 |
40 | 리눅스 프레임버퍼(Linux Frame Buffer) | makersweb | 2015.02.15 | 7500 |
39 | Ubuntu Linux에서 dbus-c++바인딩 D-Bus 테스트 | makersweb | 2018.03.07 | 7108 |
38 | 키패드 드라이버 | pjk | 2014.02.12 | 6521 |
37 | 리눅스 커널 소스코드 구성도 | makersweb | 2014.03.04 | 5494 |
36 | Build Qt 4.7.0 for Embedded Linux | makersweb | 2015.05.25 | 5424 |
» | 플랫폼 디바이스 드라이버 개발 시 많이 사용되는 커널 API 및 매크로 | makersweb | 2020.01.28 | 4874 |
34 | 리눅스 데스크탑 환경 종류 | pjk | 2015.02.11 | 4622 |
33 | 디바이스 드라이버에 대해서 | makersweb | 2014.04.19 | 4130 |
32 | Wayland에 대한 간단한 소개 | makersweb | 2017.12.29 | 3415 |
31 | file_operations | makersweb | 2014.02.27 | 3291 |
30 | 리눅스 디렉터리 구조 | makersweb | 2014.02.28 | 3237 |
29 | 4. Makefile를 작성할 때 알면 좋은 것들 | pjk | 2014.02.05 | 3066 |
28 | 리눅스 오디오 스택과 아키텍처 | makersweb | 2020.09.02 | 3006 |
27 | 리눅스에서 네트워크 구성 | makersweb | 2022.06.11 | 3005 |
26 | Weston 의 설명 및 관련 컴포넌트 | makersweb | 2020.06.03 | 2628 |