| 
									
										
										
										
											2016-08-02 19:38:01 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * QEMU PowerPC helper routines for the device tree. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2016 IBM Corp. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This code is licensed under the GPL version 2 or later. See the | 
					
						
							|  |  |  |  * COPYING file in the top-level directory. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "qemu/osdep.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-11 08:56:52 +02:00
										 |  |  | #include "target/ppc/cpu.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-23 13:31:52 +11:00
										 |  |  | #include "target/ppc/mmu-hash64.h"
 | 
					
						
							| 
									
										
										
										
											2016-08-02 19:38:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "hw/ppc/fdt.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if defined(TARGET_PPC64)
 | 
					
						
							| 
									
										
										
										
											2018-03-22 16:18:40 +11:00
										 |  |  | size_t ppc_create_page_sizes_prop(PowerPCCPU *cpu, uint32_t *prop, | 
					
						
							|  |  |  |                                   size_t maxsize) | 
					
						
							| 
									
										
										
										
											2016-08-02 19:38:01 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     size_t maxcells = maxsize / sizeof(uint32_t); | 
					
						
							|  |  |  |     int i, j, count; | 
					
						
							|  |  |  |     uint32_t *p = prop; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (i = 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) { | 
					
						
							| 
									
										
										
										
											2018-03-23 13:31:52 +11:00
										 |  |  |         PPCHash64SegmentPageSizes *sps = &cpu->hash64_opts->sps[i]; | 
					
						
							| 
									
										
										
										
											2016-08-02 19:38:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (!sps->page_shift) { | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         for (count = 0; count < PPC_PAGE_SIZES_MAX_SZ; count++) { | 
					
						
							|  |  |  |             if (sps->enc[count].page_shift == 0) { | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if ((p - prop) >= (maxcells - 3 - count * 2)) { | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         *(p++) = cpu_to_be32(sps->page_shift); | 
					
						
							|  |  |  |         *(p++) = cpu_to_be32(sps->slb_enc); | 
					
						
							|  |  |  |         *(p++) = cpu_to_be32(count); | 
					
						
							|  |  |  |         for (j = 0; j < count; j++) { | 
					
						
							|  |  |  |             *(p++) = cpu_to_be32(sps->enc[j].page_shift); | 
					
						
							|  |  |  |             *(p++) = cpu_to_be32(sps->enc[j].pte_enc); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return (p - prop) * sizeof(uint32_t); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 |