195ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick/*
295ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * (C) Copyright IBM Corporation 2004
395ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * All Rights Reserved.
495ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick *
595ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * Permission is hereby granted, free of charge, to any person obtaining a
695ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * copy of this software and associated documentation files (the "Software"),
795ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * to deal in the Software without restriction, including without limitation
895ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * on the rights to use, copy, modify, merge, publish, distribute, sub
995ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * license, and/or sell copies of the Software, and to permit persons to whom
1095ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * the Software is furnished to do so, subject to the following conditions:
1195ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick *
1295ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * The above copyright notice and this permission notice (including the next
1395ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * paragraph) shall be included in all copies or substantial portions of the
1495ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * Software.
1595ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick *
1695ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1795ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1895ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
1995ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
2095ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
2195ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2295ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * USE OR OTHER DEALINGS IN THE SOFTWARE.
2395ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick */
2495ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick
2595ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick/**
2695ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * \file mmio.h
2795ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * Functions for properly handling memory mapped IO on various platforms.
2895ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick *
2995ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick * \author Ian Romanick <idr@us.ibm.com>
3095ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick */
3195ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick
3295ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick
3395ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick#ifndef MMIO_H
3495ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick#define MMIO_H
3595ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick
36ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/glheader.h"
37576caad33e2db8f6950a33848e05cf3d42e2d918Jon Smirl
3895ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick#if defined( __powerpc__ )
3995ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick
405a46e176715b0eae7b8a715e8aec42f5a27214fcKeith Whitwellstatic INLINE uint32_t
4195ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanickread_MMIO_LE32( volatile void * base, unsigned long offset )
4295ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick{
435a46e176715b0eae7b8a715e8aec42f5a27214fcKeith Whitwell   uint32_t val;
4437cbb521d3ab8d96a8fcc0199424c0ddc70f0435Michel Dänzer
4595ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick   __asm__ __volatile__( "lwbrx	%0, %1, %2 ; eieio"
4695ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick			 : "=r" (val)
4737cbb521d3ab8d96a8fcc0199424c0ddc70f0435Michel Dänzer			 : "b" (base), "r" (offset) );
4895ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick   return val;
4995ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick}
5095ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick
5195ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick#else
5295ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick
535a46e176715b0eae7b8a715e8aec42f5a27214fcKeith Whitwellstatic INLINE uint32_t
5495ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanickread_MMIO_LE32( volatile void * base, unsigned long offset )
5595ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick{
565a46e176715b0eae7b8a715e8aec42f5a27214fcKeith Whitwell   volatile uint32_t * p = (volatile uint32_t *) (((volatile char *) base) + offset);
5795ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick   return LE32_TO_CPU( p[0] );
5895ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick}
5995ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick
6095ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick#endif
6195ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick
6295ba3524970f9f63aa518d6c3dd4e702c4941861Ian Romanick#endif /* MMIO_H */
63