Added functions to set and get the segment register (as segment_descriptor).

Added constructors to block_address_translation and segment_descriptor
that will clear its memory (could be done more efficiently though, it just
uses memset()).
Added definitions for the MSR (machine state register).
Added tlbsync() macro (direct assembler call).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5092 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2003-10-21 03:07:44 +00:00
parent 6b6c29afe6
commit db0fd9726e
2 changed files with 56 additions and 1 deletions

View File

@ -59,7 +59,14 @@ struct iframe {
uint32 r0;
};
#define MSR_IP (1L << 6)
enum machine_state {
MSR_PRIVILEGE_LEVEL = 1L << 14, // PR
MSR_FP_AVAILABLE = 1L << 13, // FP
MSR_MACHINE_CHECK_ENABLED = 1L << 12, // ME
MSR_EXCEPTION_PREFIX = 1L << 6, // IP
MSR_INST_ADDRESS_TRANSLATION = 1L << 5, // IR
MSR_DATA_ADDRESS_TRANSLATION = 1L << 4, // DR
};
struct block_address_translation;
@ -83,6 +90,18 @@ extern void set_dbat1(struct block_address_translation *bat);
extern void set_dbat2(struct block_address_translation *bat);
extern void set_dbat3(struct block_address_translation *bat);
extern void get_ibat0(struct block_address_translation *bat);
extern void get_ibat1(struct block_address_translation *bat);
extern void get_ibat2(struct block_address_translation *bat);
extern void get_ibat3(struct block_address_translation *bat);
extern void get_dbat0(struct block_address_translation *bat);
extern void get_dbat1(struct block_address_translation *bat);
extern void get_dbat2(struct block_address_translation *bat);
extern void get_dbat3(struct block_address_translation *bat);
extern void reset_ibats(void);
extern void reset_dbats(void);
//extern void sethid0(unsigned int val);
//extern unsigned int getl2cr(void);
//extern void setl2cr(unsigned int val);
@ -96,5 +115,6 @@ extern void ppc_context_switch(void **_oldStackPointer, void *newStackPointer);
#define eieio() asm volatile("eieio")
#define isync() asm volatile("isync")
#define tlbsync() asm volatile("tlbsync")
#endif /* _KERNEL_ARCH_PPC_CPU_H */

View File

@ -9,6 +9,8 @@
#include <SupportDefs.h>
#include <string.h>
#include <arch_cpu.h>
/*** BAT - block address translation ***/
@ -48,6 +50,11 @@ struct block_address_translation {
uint32 _reserved1 : 1;
uint32 protection : 2;
block_address_translation()
{
Clear();
}
void SetVirtualAddress(void *address)
{
page_index = uint32(address) >> 17;
@ -71,6 +78,21 @@ struct segment_descriptor {
uint32 no_execute_protection : 1;
uint32 _reserved : 4;
uint32 virtual_segment_id : 24;
segment_descriptor()
{
Clear();
}
segment_descriptor(uint32 value)
{
*((uint32 *)this) = value;
}
void Clear()
{
memset((void *)this, 0, sizeof(segment_descriptor));
}
};
@ -111,4 +133,17 @@ struct page_table_entry_group {
extern void ppc_get_page_table(page_table_entry_group **_pageTable, size_t *_size);
extern void ppc_set_page_table(page_table_entry_group *pageTable, size_t size);
static inline segment_descriptor
ppc_get_segment_register(void *virtualAddress)
{
return (segment_descriptor)get_sr(virtualAddress);
}
static inline void
ppc_set_segment_register(void *virtualAddress, segment_descriptor segment)
{
set_sr(virtualAddress, *(uint32 *)&segment);
}
#endif /* _KERNEL_ARCH_PPC_MMU_H */