kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: htmldeveloper@gmail.com (Peter Teoh)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Calling function from address
Date: Sat, 11 Jun 2011 14:45:40 +0700	[thread overview]
Message-ID: <BANLkTin98z7_RP+Z09soR4X+eLD=yFd+bQ@mail.gmail.com> (raw)
In-Reply-To: <20110610074638.GO13434@mailer.i88.de>

For ARM, MMU info can be found here:

http://infocenter.arm.com/help/topic/com.arm.doc.ddi0333h/Babbhigi.html

That is the theory behind MMU in ARM....but if u want the high level API, look
 under the arch/arm/mm directory lots of examples there.   Otherwise u
might try the following steps as proposed by "Marco Wang" - google for
it.   To quote:

phys_to_virt() only works with directly mapped physical address. I
don't think using phys_to_virt() is the best idea, anyway. Usually you
do this in several steps in a device driver:

1. Call request_mem_region() to request virtual memory region;
2. Call ioremap() to map physical address to virtual address;
3. Read/write mapped virtual address by using iowriteXX() /
ioreadXX(), etc. Here XX can be 8, 16, or 32 for example, represents
bit width.
4. Call iounmap() and release_mem_region() to release memory mapping;

Thanks,
Marco Wang

On Fri, Jun 10, 2011 at 3:46 PM, Micha M. <kernelnewbies@mail.i88.de> wrote:
> On Fri, Jun 10, 2011 at 07:30:46AM +0800, Gavin Guo wrote:
>> > So maybe I have to explain some more. There is some code located in the
>> > pysical address space and I need to call it from a kernel module. The
>> > problem is, that the code must be run from that location it is stored (it
>> > contains absolute jumps). So I'd like to be able to run that code in that
>> > address space, or to "tell" the keeernel to ignore page faults/memory
>> > protection on a certain address range, so that I can jump there run the
>> > code and return to the caller (kernel module)
>>
>> What is the architecture do you use? ex: x86, arm, mips,...
>
> ARM.
>
>> I know in some platform like andes, it is possible to turn off the
>> virtual memory.
>> Then you can jump to the physical address. After doing what you want, turning on
>> virtual memory again. Finally, system return to the normal operation.
>> However, the
>> code is a little tricky. Before turning off the virtual memory, you
>> must lock the
>> code jumping to physical address in cache. Otherwise, behaviors, after
>> turning off
>> the cache, is unpredictable.
>>
>> Gavin Guo
>


-- 
Regards,
Peter Teoh

  reply	other threads:[~2011-06-11  7:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-07 20:47 Calling function from address Micha M.
2011-06-07 21:10 ` Jeff Haran
2011-06-08  9:52 ` Mulyadi Santosa
2011-06-08 10:50   ` Micha M.
2011-06-08 14:49     ` emilie lefebvre
2011-06-09 19:50 ` Micha M.
     [not found]   ` <BANLkTinCsEuYb-ZPPAy_h4HWCSufHV-8vQ@mail.gmail.com>
2011-06-10  7:46     ` Micha M.
2011-06-11  7:45       ` Peter Teoh [this message]
2011-06-11  8:01         ` Peter Teoh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='BANLkTin98z7_RP+Z09soR4X+eLD=yFd+bQ@mail.gmail.com' \
    --to=htmldeveloper@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).