Exemplo n.º 1
0
static inline kern_return_t chudxnu_private_task_read_bytes(task_t task, vm_offset_t addr, int size, void *data)
{
    
    kern_return_t ret;
    
    if(task==kernel_task) {
        if(size==sizeof(unsigned int)) {
            addr64_t phys_addr;
            ppnum_t pp;

			pp = pmap_find_phys(kernel_pmap, addr);			/* Get the page number */
			if(!pp) return KERN_FAILURE;					/* Not mapped... */
			
			phys_addr = ((addr64_t)pp << 12) | (addr & 0x0000000000000FFFULL);	/* Shove in the page offset */
			
            if(phys_addr < mem_actual) {					/* Sanity check: is it in memory? */
                *((uint32_t *)data) = ml_phys_read_64(phys_addr);
                return KERN_SUCCESS;
            }
        } else {
            return KERN_FAILURE;
        }
    } else {
        
		ret = KERN_SUCCESS;									/* Assume everything worked */
		if(copyin((void *)addr, data, size)) ret = KERN_FAILURE;	/* Get memory, if non-zero rc, it didn't work */
		return ret;
    }
}
Exemplo n.º 2
0
/*
 *  Read the memory location at physical address paddr.
 *  This is a part of a device probe, so there is a good chance we will
 *  have a machine check here. So we have to be able to handle that.
 *  We assume that machine checks are enabled both in MSR and HIDs
 */
boolean_t 
ml_probe_read_64(addr64_t paddr64, unsigned int *val)
{
    if ((PAGE_SIZE - (paddr64 & PAGE_MASK)) < 4)
        return FALSE;

    *val = ml_phys_read_64((pmap_paddr_t)paddr64);
    return TRUE;
}