linux-mips
[Top] [All Lists]

Confused on cache_op(op,addr) definition in r4kcache.h in linux source c

To: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Subject: Confused on cache_op(op,addr) definition in r4kcache.h in linux source code v3.3.5
From: shawn Bai <programassem@hotmail.com>
Date: Mon, 29 Apr 2013 08:45:44 +0000
Cc: "baixy_009@163.com" <baixy_009@163.com>, "programassem@gmail.com" <programassem@gmail.com>
Importance: Normal
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
Hello, everyone,

    I'm very glag to have chance to communicate with you in this maling list.

    I'm involved in a SOC project making use of MIPS24K core.
    While learning the CACHE aspects in Linux kernel source code v3.3.5,  I 
found the macro definition for cache operations.

     It goes as:

#define cache_op(op,addr)                        \
    __asm__ __volatile__(                        \
    "    .set    push                    \n"    \
    "    .set    noreorder                \n"    \
    "    .set    mips3\n\t                \n"    \
    "    cache    %0, %1                    \n"    \
    "    .set    pop                    \n"    \
    :                                \
    : "i" (op), "R" (*(unsigned char *)(addr)))


  "i" (op)   as argument 0 in CACHE instruction,
  "R" (*(unsigned char *)(addr))   as argument 1 in CACHE instruction


  Further, on the other hand, the CACHE instruction in MIPS ISA is like this:

Format:      CACHE op, offset(base)

Purpose: Perform Cache Operation

To perform the cache operation specified by op.

  And as know,  depending on the  op field,   the offset(base) coud be 
understood accordingly for different meanings.

Well, after the context, here below is what makes me confused.

In the cache_op inline assembly,   
why "R" (*(unsigned char *)(addr))   is used as the argument 1 of CACHE 
instruction, instead of   "R" ((unsigned char *)(addr)) ?

the argument 1 numbered from 0  in CACHE instruction in MIPS ISA  should be a 
address with a offset,  but from the code,  it seems that the value in that 
address  is passed to CACHE instruction.

Could someone give some help on this?  
I really appreciate that.
Thanks in advance.




Best regards,
Shawn Bai                                         
<Prev in Thread] Current Thread [Next in Thread>
  • Confused on cache_op(op,addr) definition in r4kcache.h in linux source code v3.3.5, shawn Bai <=