mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
Define the translations property for cpu (Laurent Vivier)
git-svn-id: svn://coreboot.org/openbios/openbios-devel@333 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "ofmem.h"
|
||||
#include "openbios-version.h"
|
||||
#include "libc/byteorder.h"
|
||||
#include "libc/vsprintf.h"
|
||||
#define NO_QEMU_PROTOS
|
||||
#include "openbios/fw_cfg.h"
|
||||
|
||||
@@ -424,6 +425,7 @@ arch_of_init( void )
|
||||
#endif
|
||||
uint64_t ram_size;
|
||||
const struct cpudef *cpu;
|
||||
char buf[64];
|
||||
|
||||
devtree_init();
|
||||
|
||||
@@ -485,6 +487,8 @@ arch_of_init( void )
|
||||
#ifdef CONFIG_DRIVER_PCI
|
||||
ob_pci_init();
|
||||
#endif
|
||||
snprintf(buf, sizeof(buf), "/cpus/%s", cpu->name);
|
||||
ofmem_register(find_dev(buf));
|
||||
node_methods_init();
|
||||
|
||||
#ifdef USE_RTAS
|
||||
|
||||
@@ -110,6 +110,36 @@ get_ram_bottom( void )
|
||||
return (ulong)OF_MALLOC_BASE;
|
||||
}
|
||||
|
||||
static phandle_t cpu_handle = 0;
|
||||
static void
|
||||
ofmem_update_translations( void )
|
||||
{
|
||||
ofmem_t *ofmem = OFMEM;
|
||||
translation_t *t;
|
||||
int ncells;
|
||||
cell *props;
|
||||
|
||||
if (cpu_handle == 0)
|
||||
return;
|
||||
|
||||
for( t = ofmem->trans, ncells = 0; t ; t=t->next, ncells++ )
|
||||
;
|
||||
|
||||
props = malloc(ncells * sizeof(cell) * 4);
|
||||
if (props == NULL)
|
||||
return;
|
||||
|
||||
for( t = ofmem->trans, ncells = 0 ; t ; t=t->next ) {
|
||||
props[ncells++] = t->virt;
|
||||
props[ncells++] = t->size;
|
||||
props[ncells++] = t->phys;
|
||||
props[ncells++] = t->mode;
|
||||
}
|
||||
set_property(cpu_handle, "translations",
|
||||
(char*)props, ncells * sizeof(cell));
|
||||
free(props);
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* OF private allocations */
|
||||
/************************************************************************/
|
||||
@@ -502,6 +532,8 @@ map_page_range( ulong virt, ulong phys, ulong size, int mode )
|
||||
t->next = *tt;
|
||||
*tt = t;
|
||||
|
||||
ofmem_update_translations();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -703,3 +735,10 @@ ofmem_init( void )
|
||||
ofmem_claim_phys( get_ram_top(), get_ram_size() - get_ram_top(), 0);
|
||||
ofmem_claim_virt( get_ram_top(), get_ram_size() - get_ram_top(), 0);
|
||||
}
|
||||
|
||||
void
|
||||
ofmem_register( phandle_t ph )
|
||||
{
|
||||
cpu_handle = ph;
|
||||
ofmem_update_translations();
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ ulong get_ram_bottom( void );
|
||||
void dsi_exception( void );
|
||||
void isi_exception( void );
|
||||
void setup_mmu( ulong ramsize );
|
||||
void ofmem_register( phandle_t ph );
|
||||
#endif
|
||||
|
||||
#endif /* _H_OFMEM */
|
||||
|
||||
Reference in New Issue
Block a user