Subject: how to include mips assembly in c code?

From: "durai" <[email-masked]>
Date: Thu, 9 Oct 2003 11:08:56 +0530

hello,
I am having the following assembly code and i wanted to call this function from a c code.
can anybody tell me how to include this code in a c program?

/******************************************************************************
*
* sysWbFlush - flush the write buffer
*
* This routine flushes the write buffers, making certain all
* subsequent memory writes have occurred.  It is used during critical periods
* only, e.g., after memory-mapped I/O register access.
*
* RETURNS: N/A

* sysWbFlush (void)

*/
        .ent    sysWbFlush
sysWbFlush:
        li      t0, K1BASE              /* load uncached address        */
        lw      t0, 0(t0)               /* read in order to flush       */
        j       ra                      /* return to caller             */
        .end    sysWbFlush

regards
durai

---

From: Ralf Baechle <[email-masked]>
Date: Thu, 9 Oct 2003 09:54:15 +0200

> can anybody tell me how to include this code in a c program?

Several solutions:

  #define sysWbFlush()	 do { (*(volatile unsigned int *)K1BASE) } while (0)

Or using your existing code:

  extern void sysWbFlush(void);

the call as

  sysWbFlush();

No point in using inline assembler for such a small fragment.

Anyway - I suggest you dump this code and look at <asm/wbflush.h>.

  Ralf

---

From: Matthew Dharm <[email-masked]>
Date: Thu, 9 Oct 2003 01:05:39 -0700

I feel compelled to point out that the source file you are quoting looks
suspiciously like it came from VxWorks, which means it is likely copyright
Wind River Systems.  Using their code without permission would be illegal.

Matt

-- 
Matthew Dharm                              Work: [email-masked]
Senior Software Designer, Momentum Computer

---

From: [email-masked]
Date: Thu, 9 Oct 2003 14:47:06 -0700

Here we go - whole six lines of code! What a terrible copyright infigement!

---

From: Wolfgang Denk <[email-masked]>
Date: Fri, 10 Oct 2003 00:09:45 +0200

> Here we go - whole six lines of code! What a terrible copyright infigement!

Six lines of code, and 12  lines  of  obvious  comments,  and  pretty
obvious  function  names - this is exactly what the Evil Empire (like
SCO et al) is looking for.

Please try and be a little less ignorant.

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: [email-masked]
In Nature there are neither rewards nor punishments, there are conse-
quences.                                            -- R.G. Ingersoll