펑션콜??? 에 대해서 질문 드립니다.

mailbox20의 이미지

ac97 디바이스 드라이버에서 아래와 같은 구조체가 있습니다.

================================================
struct ac97_codec {
:
:
void (*codec_write) (struct ac97_codec *codec, u8 reg, u16 val);
:
:
};

================================================

아래와 같이 선언된 상황에서
struct ac97_codec codec;

아래와 같이 사용될때 아래 코드의 의미를 잘 모르겠습니다.
codec->codec_write(codec, AC97_GPIO_STATUS, wm_gpio_stat);

codec_write(codec, AC97_GPIO_STATUS, wm_gpio_stat) 이 함수가 따로 선언되어 있는것도 아니고
단지 ac97_codec구조체 내에서 void (*codec_write) (struct ac97_codec *codec, u8 reg, u16 val); 이런식으로 선언되어 있는것 뿐인데 동작은 어떻게 되는건지... 잘 모르겠네요.

그리고 이런식으로 사용하는게 펑션콜이 맞긴 하죠?

아시는 분 ~ 좀 알려 주세요~
그럼 좋은 하루 되시길~

hey의 이미지

그런 코드의 경우 실제로는 정확히 모르겠지만 일반적으로 만들어서 넣으라는 의미일 겁니다.


----------------------------
May the F/OSS be with you..


익명 사용자의 이미지

function pointer에 관해 검색해보세요.

익명 사용자의 이미지

struct ac97_codec {
void (*codec_write) (struct ac97_codec *codec, u8 reg, u16 val);
};

struct ac97_codec codec;

/* 여기부터 추가된 부분입니다. */

static customized_codec_write (struct ac97_codec *codec, u8 reg, u16 val)
{
/// Blahblah... DEBUG_MESG는 stdout출력을 내보내는 함수라고 가정
DEBUG_MESG("%s]\n",__FUCTION__);
}

codec =
{
customized_codec_write,
};
/* 여기까지, 'codec' 변수는 header파일에서 extern선언이 되어있거나 export symbol이 되어있다고 가정하고... */

codec->codec_write(codec, AC97_GPIO_STATUS, wm_gpio_stat);
(위와 같이 호출하면)

"customized_codec_write]"

stdout에 위와 같이 출력됩니다.

(맞나요? -_-a)

익명 사용자의 이미지

코덱은 다양하겠지요?

보통 이런 유형의 프로그램이 전형적인 프레임워크의 유형입니다.

소위 기본 호출 유형과 최소 코덱만 구현이 되어 제공되는 경우겠습니다.
새로운 코덱의 추가를 위해서는 로마법에 따라서 짜라는 얘기가 되겠습니다.

mailbox20의 이미지

답변 고맙습니다.
이해가 ㅤㄷㅚㅆ습니다. ^^

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.