LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-08-2011, 09:18 AM   #1
metheor
LQ Newbie
 
Registered: Aug 2011
Posts: 3

Rep: Reputation: Disabled
How to make arch_decomp_wdog function able to run in both physical/virtual memory


Is there some easy way I can detect if the kernel is running in physical memory (kernel decompression) or in virtual memory (initramfs decompression). The reason for this, is that I would like to implement an arch_decomp_wdog function that kicks the CPU HW watchdog using calls that are available in each mode.
 
Old 08-09-2011, 07:06 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
The kernel always runs in (non-paged) physical memory.
I haven't looked at this, but logically the decompression will take place before the initramfs is invoked. Think about what happens if the initramfs is embedded in the kernel itself.
 
Old 08-09-2011, 07:53 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,647
Blog Entries: 4

Rep: Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933
initramfs runs in Neverland.

In its magickal world, "'the system,' as it were, 'really does not exist yet.'" Uh huh. "The BIOS has done its thing, and then grub (or lilo) has done its thing, but we're just not quite ready yet."

In that magickal, transcendental, but nevertheless very necessary state, "all bets are off, and it is understood." Therefore, "if you are there, then it is presumed that you know that you are there, and you therefore have no need to 'detect' it."

My advice: choose one appropriate moment, and therefore one appropriate environment, in which to unleash your friendly dogs.
 
Old 08-09-2011, 09:48 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
From a cursory look, nothing too magical.
The boot-loader loads it (and the kernel obviously), and updates the kernel header record with the address and size of the initrd(fs).
The bootloader branches to the kernel which uncompresses itself and does its thing. If an initrd was passed, it gets mounted and (initrd) init run. Just looks like an early userspace prior to the real root being mounted.
 
Old 08-10-2011, 02:22 AM   #5
metheor
LQ Newbie
 
Registered: Aug 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
Additional details on the arch_decomp_wdog question

Thanks for all replies so far!
Some additional details about the watchdog kick.
The system is an ARM9-based one where the CPU watchdog has been enabled from the bootstrap.
Depending on how far we have come with the kernel initialization, the MMU is either off or on.
It seems that we need to access the watchdog HW differently, depending on if we have the MMU enabled or not.
An untested attempt:

Quote:
static inline void arch_decomp_wdog(void)
{
unsigned int regval;

/* Read MMU Register */
asm volatile ("MRC p15, 0, %0, c1, c0, 0\t\n": "=r"(regval));

if(regval & 1)
{
/* MMU active - Use macros that remap IO addresses based on AT91_VA_BASE_SYS */
at91_sys_write(AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT);
}
else
{
/* Physical memory (before MMU is enabled) */
__raw_writel(AT91_WDT_KEY | AT91_WDT_WDRSTT, ((void __iomem *) AT91_BASE_SYS) + AT91_WDT_CR);
}
}

Does this make sense?

Last edited by metheor; 08-10-2011 at 02:26 AM. Reason: Code formatting
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
virtual address to physical memory access pupillo Linux - General 2 02-22-2010 10:07 AM
Swap space did not function when physical memory ( RAM ) is full rabbit00 Linux - Newbie 19 07-06-2009 09:18 PM
Physical Memory and Virtual Memory Murdock1979 Linux - General 1 01-28-2008 07:35 AM
how can i run 3 linux virtual machines without going out of physical memory asterik123 General 7 04-14-2007 05:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 08:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration