Results 1 to 5 of 5

Thread: u32 version is initialized to HW_REVID(1, 0, 0, 0, 0, 0, 0) how is it happening

  1. #1
    Join Date
    Jun 2010
    Beans
    380

    u32 version is initialized to HW_REVID(1, 0, 0, 0, 0, 0, 0) how is it happening

    http://lxr.free-electrons.com/source...8139too.c#L503
    On above link a structure is defined
    Code:
    static const struct {
            const char *name;
            u32 version; /* from RTL8139C/RTL8139D docs */
            u32 flags;
    }
    in the structure there is a datatype
    Code:
    u32 version
    which is initialized as
    Code:
      HW_REVID(1, 0, 0, 0, 0, 0, 0),
    I am not clear with what is
    1) u32 version
    2) How u32 version is initialized to HW_REVID(1, 0, 0, 0, 0, 0, 0)

  2. #2
    Join Date
    May 2006
    Beans
    1,787

    Re: u32 version is initialized to HW_REVID(1, 0, 0, 0, 0, 0, 0) how is it happening

    Quote Originally Posted by jamesbon View Post
    http://lxr.free-electrons.com/source...8139too.c#L503
    On above link a structure is defined
    Code:
    static const struct {
            const char *name;
            u32 version; /* from RTL8139C/RTL8139D docs */
            u32 flags;
    }
    in the structure there is a datatype
    Code:
    u32 version
    which is initialized as
    Code:
      HW_REVID(1, 0, 0, 0, 0, 0, 0),
    I am not clear with what is
    1) u32 version
    2) How u32 version is initialized to HW_REVID(1, 0, 0, 0, 0, 0, 0)
    Somewhere in the code, there is probably some line looking like "typedef sometype u32;". And another line defining the macro HW_REVID. They are probably in some header file. Look for them.

  3. #3
    Join Date
    Jun 2010
    Beans
    380

    Re: u32 version is initialized to HW_REVID(1, 0, 0, 0, 0, 0, 0) how is it happening

    Ok I looked at it as you wanted to tell.
    Code:
    typedef uint32_t u32;
    and
    Code:
    #define u32 unsigned int
    So I understand the version is an unsigned int
    Now
    Line number 498 on same link

    Code:
    #define HW_REVID(b30, b29, b28, b27, b26, b23, b22) \
            (b30<<30 | b29<<29 | b28<<28 | b27<<27 | b26<<26 | b23<<23 | b22<<22)
    is defining this macro.
    So in this case the structure
    Code:
    static const struct {
            const char *name;
            u32 version; /* from RTL8139C/RTL8139D docs */
            u32 flags;
    } rtl_chip_info[] = {
            { "RTL-8139",
              HW_REVID(1, 0, 0, 0, 0, 0, 0),
              HasHltClk,
            },
    gets expanded to
    Code:
    static const struct {
            const char *name;
            u32 version; /* from RTL8139C/RTL8139D docs */
            u32 flags;
    } rtl_chip_info[] = {
            { "RTL-8139",
     (b30, b29, b28, b27, b26, b23, b22) 
            (b30<<30 | b29<<29 | b28<<28 | b27<<27 | b26<<26 | b23<<23 | b22<<22) 
    (1, 0, 0, 0, 0, 0, 0),
              HasHltClk,
            },
    Last edited by jamesbon; November 14th, 2010 at 03:59 AM.

  4. #4
    Join Date
    Apr 2005
    Location
    Hampshire, UK
    Beans
    1,274

    Re: u32 version is initialized to HW_REVID(1, 0, 0, 0, 0, 0, 0) how is it happening

    Quote Originally Posted by jamesbon View Post
    gets expanded to
    Code:
    static const struct {
            const char *name;
            u32 version; /* from RTL8139C/RTL8139D docs */
            u32 flags;
    } rtl_chip_info[] = {
            { "RTL-8139",
     (b30, b29, b28, b27, b26, b23, b22) 
            (b30<<30 | b29<<29 | b28<<28 | b27<<27 | b26<<26 | b23<<23 | b22<<22) 
    (1, 0, 0, 0, 0, 0, 0),
              HasHltClk,
            },
    No, it gets expanded to:

    Code:
    static const struct {
            const char *name;
            u32 version; /* from RTL8139C/RTL8139D docs */
            u32 flags;
    } rtl_chip_info[] = {
            { "RTL-8139",
            (1<<30 | 0<<29 | 0<<28 | 0<<27 | 0<<26 | 0<<23 | 0<<22), 
              HasHltClk,
            },

  5. #5
    Join Date
    Jun 2010
    Beans
    380

    Re: u32 version is initialized to HW_REVID(1, 0, 0, 0, 0, 0, 0) how is it happening

    Ok that makes it clear.Thanks for helping out.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •