한국어
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)

 

번호 제목 글쓴이 날짜 조회 수
24 Wayland에 대한 간단한 소개 file makersweb 2017.12.29 3369
23 NFS를 통해 파일시스템 공유 makersweb 2018.03.05 1134
22 Ubuntu Linux에서 dbus-c++바인딩 D-Bus 테스트 file makersweb 2018.03.07 7058
21 tslib 크로스 컴파일과 터치스크린 보정 makersweb 2018.08.02 2178
20 libblkid - USB Storage의 정보 가져오기 makersweb 2018.10.18 674
19 리눅스 컴파일러 최신으로 업데이트 linux 2018.12.26 1899
18 PATH에 새로운 경로 추가 makersweb 2019.09.19 398
» 플랫폼 디바이스 드라이버 개발 시 많이 사용되는 커널 API 및 매크로 makersweb 2020.01.28 4711
16 initramfs (initial ram file system: 초기 램 파일 시스템) makersweb 2020.02.25 2035
15 64비트 리눅스에서 32비트 응용프로그램을 실행하려면 makersweb 2020.02.29 1772
14 Weston 의 설명 및 관련 컴포넌트 makersweb 2020.06.03 2475
13 Wayland 의 주요 객체들 makersweb 2020.06.04 891
12 Wayland 의 Client Application 프로그래밍 기본 루틴 makersweb 2020.06.04 1644
11 wayland-scanner 를 통해 Wayland 프로토콜 코드생성 makersweb 2020.06.08 921
10 리눅스 오디오 스택과 아키텍처 file makersweb 2020.09.02 2873
9 dbus-broker를 기본 DBus 구현으로 설정 makersweb 2021.01.20 1184
8 SocketCAN 유틸 사용방법 file makersweb 2022.02.05 7024
7 ifconfig 는 대부분 ip 명령으로 대체 makersweb 2022.02.12 1467
6 D-Bus ObjectManager file makersweb 2022.02.12 621
5 리눅스에서 네트워크 구성 makersweb 2022.06.11 2863