본문 바로가기

[Debugging] Tips

[리눅스커널] 디바이스 트리: of_root 디버깅

디바이스 트리를 관리하는 주요 자료 구조는 다음과 같습니다.
 
   * of_root
   * of_aliases
   * of_chosen
   * of_stdout
 
of_root
 
of_root 전역 변수는 다음과 같습니다.
 
  of_root = 0xF6B49F44 -> (
    name = 0xF6B4A16C -> "",
    type = 0xC157AEAB -> "<NULL>",
    phandle = 0,
    full_name = 0xF6B49F94 -> "/",
    properties = 0xF6B49F98,
    deadprops = 0x0,
    parent = 0x0,
    child = 0xF6B4A170 -> (
      name = 0xF6B4A264 -> "cpus",
      type = 0xC157AEAB -> "<NULL>",
      phandle = 0,
      full_name = 0xF6B4A1C0 -> "/cpus",  // '/cpu' 노드가 자식임
      properties = 0xF6B4A1C8,
      deadprops = 0x0,
      parent = 0xF6B49F44,
      child = 0xF6B4A26C,
      sibling = 0xF6B4DD28,
      kobj = (name = 0xF562FF00 -> "cpus", entry = (next = 0xF6B4A294, prev = 0xF6B49F6C), parent = 0xF6B49F68, kse
      _flags = 0,
      data = 0x0),
    sibling = 0x0,
    kobj = (name = 0xF562FC40 -> "base", entry = (next = 0xF6B4A198, prev = 0xF562FB40), parent = 0xF562FB4C, kset
    _flags = 16,
    data = 0x0)
 
 
0xF6B4A170 주소에 있는 '/cpu' 노드의 sibling 정보를 확인하면 '/soc'로 확인됩니다.
 
  of_root = 0xF6B49F44 -> (
    name = 0xF6B4A16C -> "",
    type = 0xC157AEAB -> "<NULL>",
    phandle = 0,
    full_name = 0xF6B49F94 -> "/",
...
    parent = 0x0,
    child = 0xF6B4A170 -> (
      name = 0xF6B4A264 -> "cpus",
      type = 0xC157AEAB -> "<NULL>",
      phandle = 0,
      full_name = 0xF6B4A1C0 -> "/cpus",
      properties = 0xF6B4A1C8,
      deadprops = 0x0,
      parent = 0xF6B49F44,
      child = 0xF6B4A26C,
      sibling = 0xF6B4DD28 -> (
        name = 0xF6B4DE84 -> "soc",
        type = 0xC157AEAB -> "<NULL>",
        phandle = 0,
        full_name = 0xF6B4DD78 -> "/soc",
        properties = 0xF6B4DD80,
        deadprops = 0x0,
        parent = 0xF6B49F44,
        child = 0xF6B4DE88,
        sibling = 0xF6BE855C,
...
 
'/soc'의 sibling 정보를 확인하면, 아래와 같습니다.
 
      sibling = 0xF6B4DD28 -> (
        name = 0xF6B4DE84 -> "soc",
        type = 0xC157AEAB -> "<NULL>",
        phandle = 0,
        full_name = 0xF6B4DD78 -> "/soc",
        properties = 0xF6B4DD80,
        deadprops = 0x0,
        parent = 0xF6B49F44,
        child = 0xF6B4DE88,
        sibling = 0xF6BE855C -> (
          name = 0xF6BE8754 -> "chosen",
          type = 0xC157AEAB -> "<NULL>",
          phandle = 0,
          full_name = 0xF6BE85AC -> "/chosen",
          properties = 0xF6BE85B4,
          deadprops = 0x0,
          parent = 0xF6B49F44,
          child = 0x0,
          sibling = 0xF6BE875C -> (
            name = 0xF6BE8BC8 -> "aliases",
            type = 0xC157AEAB -> "<NULL>",
            phandle = 0,
            full_name = 0xF6BE87AC -> "/aliases",
            properties = 0xF6BE87B8,
            deadprops = 0x0,
            parent = 0xF6B49F44,
            child = 0x0,
            sibling = 0xF6BE8BD0 -> (
              name = 0xF6BE8CC4 -> "memory",
              type = 0xC3437FD0 -> "memory",
              phandle = 0,
              full_name = 0xF6BE8C20 -> "/memory",
 
이 정보를 참고로 트리 구조는 다음과 같이 그릴 수 있습니다.
 
/
  |--- /cpus
  |--- /soc
  |--- /chosen
  |--- /aliases
  |--- /memory
  |--- /firmware
  |--- /reserved-memory
  |--- /psci
 
            sibling = 0xF6BE8BD0 -> (
              name = 0xF6BE8CC4 -> "memory",
              type = 0xC3437FD0 -> "memory",
              phandle = 0,
              full_name = 0xF6BE8C20 -> "/memory",
              properties = 0xF6BE8C28,
              deadprops = 0x0,
              parent = 0xF6B49F44,
              child = 0x0,
              sibling = 0xF6BE8CCC -> (
                name = 0xF6BE8D5C -> "firmware",
                type = 0xC157AEAB -> "<NULL>",
                phandle = 0,
                full_name = 0xF6BE8D1C -> "/firmware",
                properties = 0xF6BE8D28,
                deadprops = 0x0,
                parent = 0xF6B49F44,
                child = 0xF6BE8D68,
                sibling = 0xF6BE92DC -> (
                  name = 0xF6BE9410 -> "reserved-memory",
                  type = 0xC157AEAB -> "<NULL>",
                  phandle = 0,
                  full_name = 0xF6BE932C -> "/reserved-memory",
                  properties = 0xF6BE9340,
                  deadprops = 0x0,
                  parent = 0xF6B49F44,
                  child = 0xF6BE9420,
                  sibling = 0xF6BEAA14 -> (
                    name = 0xF6BEAB08 -> "psci",
                    type = 0xC157AEAB -> "<NULL>",
                    phandle = 0,
                    full_name = 0xF6BEAA64 -> "/psci",
                    properties = 0xF6BEAA6C,