리눅스 drivers 디렉토리 안의 driver들의 register는 언제 호출이 되는 건가요?

ryutuna의 이미지

안녕하세요.

우선 platform device와 driver에 대한 공부를 하는 도중입니다.

platform device에 매칭되는 platform driver의 초기화 함수인 probe()들은

platform_driver_register()
->driver_register()
->bus_add_driver()
->driver_attach()
->bus_for_each_dev()
->__driver_attach()
->driver_probe_device()
->really_probe()

의 과정을 통해서 호출이 된다는 것을 확인 했습니다.

제가 알고 싶은 것은

그렇다면 대체 어디서 platform driver에 대한 등록 함수인 platform_driver_register()가 호출이 되느냐는 건데요,

리눅스 커널의 drivers 디렉토리안에 있는 platform driver 소스들을 보면 module_init함수로 등록 된 함수들 안에서

platform_driver_register()를 호출 하는 것을 확인 할 수 있습니다.

찾아본 결과, platform device가 먼저 등록이 되고 platform driver들이 등록이 되면서 platform_driver_register()를 호출,

위의 driver_attach()에서 매칭되는 device를 여부를 확인 후 probe()를 호출 하는 것으로 확인 했는데요,

kerenl이 부팅되는 과정에서

해당 machine(board)가 init 되는 과정에서 platform_add_devices()나 platform_device_register()를 통해

device들을 등록하는 부분까지는 찾았으나 platform driver들에 대한 등록은 어디서 이루어 지는지를 모르겠네요.

질문의 의도를 약간 다르게 해석하자면, drivers 디렉토리 안의 platform driver들의 module_init

함수들은 어디서 호출이 되는 가에 대한 것입니다.

bushi의 이미지

대표적인 곳으로 init/main.c 의 do_initcalls() 를 보시면 되겠습니다.
완전히 이해를 하려면 include/linux/init.h 에 정의된 .init 관련 섹션 지정 매크로들과
링크 스크립트(ex: arch/arm/kernel/vmlinux.lds.S)까지 보셔야 합니다.

bushi의 이미지

언젠가 코드를 올렸던 기억이 나서 찾아봤습니다.
http://kldp.org/node/107263#comment-497310

ryutuna의 이미지

많은 도움이 되었습니다. 관심에 감사드립니다!

--------------------------------------------------------------
세상엔 알아야 할 것도 알지 말았어야 할 것도 너무 많았습니다.

ryutuna의 이미지

관련 정보를 잘 정리한 곳이 있어서 링크를 걸어둡니다.

http://blog.daum.net/baramjin/16010994

--------------------------------------------------------------
세상엔 알아야 할 것도 알지 말았어야 할 것도 너무 많았습니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.