1*7c478bd9Sstevel@tonic-gate/* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate/* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate#pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate/* 30*7c478bd9Sstevel@tonic-gate * Assembly language support for physical big/little endian access of pcitool 31*7c478bd9Sstevel@tonic-gate * in the PCI drivers. 32*7c478bd9Sstevel@tonic-gate */ 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate#include <sys/asm_linkage.h> 35*7c478bd9Sstevel@tonic-gate#include <sys/machthread.h> 36*7c478bd9Sstevel@tonic-gate#include <sys/privregs.h> 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate/*LINTLIBRARY*/ 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate#if defined(lint) 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate/*ARGSUSED*/ 43*7c478bd9Sstevel@tonic-gateint pci_do_phys_peek(size_t size, uint64_t paddr, uint64_t *value, int type) 44*7c478bd9Sstevel@tonic-gate{ return (0); } 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gateint pci_do_phys_poke(size_t size, uint64_t paddr, uint64_t *value, int type) 47*7c478bd9Sstevel@tonic-gate{ return (0); } 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate#else /* lint */ 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate! pci_do_phys_peek: Do physical address read. 52*7c478bd9Sstevel@tonic-gate! 53*7c478bd9Sstevel@tonic-gate! %o0 is size in bytes - Must be 8, 4, 2 or 1. Invalid sizes default to 1. 54*7c478bd9Sstevel@tonic-gate! %o1 is address to read 55*7c478bd9Sstevel@tonic-gate! %o2 is address to save value into 56*7c478bd9Sstevel@tonic-gate! %o3 is 0 for little endian, non-zero for big endian 57*7c478bd9Sstevel@tonic-gate! 58*7c478bd9Sstevel@tonic-gate! To be called from an on_trap environment. 59*7c478bd9Sstevel@tonic-gate! Interrupts will be disabled for the duration of the read, to prevent 60*7c478bd9Sstevel@tonic-gate! an interrupt from raising the trap level to 1 and then a possible 61*7c478bd9Sstevel@tonic-gate! data access exception being delivered while the trap level > 0. 62*7c478bd9Sstevel@tonic-gate! 63*7c478bd9Sstevel@tonic-gate! Assumes alignment is correct. 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate ENTRY(pci_do_phys_peek) 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate rdpr %pstate, %o4 ! Disable interrupts if not already 68*7c478bd9Sstevel@tonic-gate andcc %o4, PSTATE_IE, %g2 ! Save original state first 69*7c478bd9Sstevel@tonic-gate bz .peek_ints_disabled 70*7c478bd9Sstevel@tonic-gate nop 71*7c478bd9Sstevel@tonic-gate wrpr %o4, PSTATE_IE, %pstate 72*7c478bd9Sstevel@tonic-gate.peek_ints_disabled: 73*7c478bd9Sstevel@tonic-gate 74*7c478bd9Sstevel@tonic-gate tst %o3 ! Set up %asi with modifier for 75*7c478bd9Sstevel@tonic-gate movz %xcc, ASI_IOL, %g1 ! Big/little endian physical space 76*7c478bd9Sstevel@tonic-gate movnz %xcc, ASI_IO, %g1 77*7c478bd9Sstevel@tonic-gate mov %g1, %asi 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate cmp %o0, 8 ! 64-bit? 80*7c478bd9Sstevel@tonic-gate bne .peek_int 81*7c478bd9Sstevel@tonic-gate cmp %o0, 4 ! 32-bit? 82*7c478bd9Sstevel@tonic-gate ldxa [%o1]%asi, %g1 83*7c478bd9Sstevel@tonic-gate ba .peekdone 84*7c478bd9Sstevel@tonic-gate stx %g1, [%o2] 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate.peek_int: 87*7c478bd9Sstevel@tonic-gate bne .peek_half 88*7c478bd9Sstevel@tonic-gate cmp %o0, 2 ! 16-bit? 89*7c478bd9Sstevel@tonic-gate lduwa [%o1]%asi, %g1 90*7c478bd9Sstevel@tonic-gate ba .peekdone 91*7c478bd9Sstevel@tonic-gate stuw %g1, [%o2] 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate.peek_half: 94*7c478bd9Sstevel@tonic-gate bne .peek_byte 95*7c478bd9Sstevel@tonic-gate nop 96*7c478bd9Sstevel@tonic-gate lduha [%o1]%asi, %g1 97*7c478bd9Sstevel@tonic-gate ba .peekdone 98*7c478bd9Sstevel@tonic-gate stuh %g1, [%o2] 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate.peek_byte: 101*7c478bd9Sstevel@tonic-gate lduba [%o1]%asi, %g1 ! 8-bit! 102*7c478bd9Sstevel@tonic-gate stub %g1, [%o2] 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate.peekdone: 105*7c478bd9Sstevel@tonic-gate membar #Sync ! Make sure the loads take 106*7c478bd9Sstevel@tonic-gate tst %g2 ! No need to reenable interrupts 107*7c478bd9Sstevel@tonic-gate bz .peek_ints_done ! if not enabled at entry 108*7c478bd9Sstevel@tonic-gate rdpr %pstate, %o4 109*7c478bd9Sstevel@tonic-gate wrpr %o4, PSTATE_IE, %pstate 110*7c478bd9Sstevel@tonic-gate.peek_ints_done: 111*7c478bd9Sstevel@tonic-gate mov %g0, %o0 112*7c478bd9Sstevel@tonic-gate retl 113*7c478bd9Sstevel@tonic-gate nop 114*7c478bd9Sstevel@tonic-gate SET_SIZE(pci_do_phys_peek) 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate 117*7c478bd9Sstevel@tonic-gate! pci_do_phys_poke: Do physical address write. 118*7c478bd9Sstevel@tonic-gate! 119*7c478bd9Sstevel@tonic-gate! %o0 is size in bytes - Must be 8, 4, 2 or 1. Invalid sizes default to 1. 120*7c478bd9Sstevel@tonic-gate! %o1 is address to write to 121*7c478bd9Sstevel@tonic-gate! %o2 is address to read from 122*7c478bd9Sstevel@tonic-gate! %o3 is 0 for little endian, non-zero for big endian 123*7c478bd9Sstevel@tonic-gate! 124*7c478bd9Sstevel@tonic-gate! Always returns success (0) in %o0 125*7c478bd9Sstevel@tonic-gate! 126*7c478bd9Sstevel@tonic-gate! Assumes alignment is correct and that on_trap handling has been installed 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate ENTRY(pci_do_phys_poke) 129*7c478bd9Sstevel@tonic-gate 130*7c478bd9Sstevel@tonic-gate tst %o3 131*7c478bd9Sstevel@tonic-gate bz .poke_asi_set 132*7c478bd9Sstevel@tonic-gate mov ASI_IOL, %asi 133*7c478bd9Sstevel@tonic-gate mov ASI_IO, %asi 134*7c478bd9Sstevel@tonic-gate.poke_asi_set: 135*7c478bd9Sstevel@tonic-gate 136*7c478bd9Sstevel@tonic-gate cmp %o0, 8 ! 64 bit? 137*7c478bd9Sstevel@tonic-gate bne .poke_int 138*7c478bd9Sstevel@tonic-gate cmp %o0, 4 ! 32-bit? 139*7c478bd9Sstevel@tonic-gate ldx [%o2], %g1 140*7c478bd9Sstevel@tonic-gate ba .pokedone 141*7c478bd9Sstevel@tonic-gate stxa %g1, [%o1]%asi 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate.poke_int: 144*7c478bd9Sstevel@tonic-gate bne .poke_half 145*7c478bd9Sstevel@tonic-gate cmp %o0, 2 ! 16-bit? 146*7c478bd9Sstevel@tonic-gate lduw [%o2], %g1 147*7c478bd9Sstevel@tonic-gate ba .pokedone 148*7c478bd9Sstevel@tonic-gate stuwa %g1, [%o1]%asi 149*7c478bd9Sstevel@tonic-gate 150*7c478bd9Sstevel@tonic-gate.poke_half: 151*7c478bd9Sstevel@tonic-gate bne .poke_byte 152*7c478bd9Sstevel@tonic-gate nop 153*7c478bd9Sstevel@tonic-gate lduh [%o2], %g1 154*7c478bd9Sstevel@tonic-gate ba .pokedone 155*7c478bd9Sstevel@tonic-gate stuha %g1, [%o1]%asi 156*7c478bd9Sstevel@tonic-gate 157*7c478bd9Sstevel@tonic-gate.poke_byte: 158*7c478bd9Sstevel@tonic-gate ldub [%o2], %g1 ! 8-bit! 159*7c478bd9Sstevel@tonic-gate stuba %g1, [%o1]%asi 160*7c478bd9Sstevel@tonic-gate 161*7c478bd9Sstevel@tonic-gate.pokedone: 162*7c478bd9Sstevel@tonic-gate membar #Sync 163*7c478bd9Sstevel@tonic-gate retl 164*7c478bd9Sstevel@tonic-gate mov %g0, %o0 165*7c478bd9Sstevel@tonic-gate SET_SIZE(pci_do_phys_poke) 166*7c478bd9Sstevel@tonic-gate 167*7c478bd9Sstevel@tonic-gate#endif 168