diff -Naur mesa-14-08-2009/configs/linux-solo mesa/configs/linux-solo
--- mesa-14-08-2009/configs/linux-solo	2009-08-19 16:00:48.000000000 +0200
+++ mesa/configs/linux-solo	2009-08-25 11:47:04.000000000 +0200
@@ -51,4 +51,4 @@
 PROGRAM_DIRS = miniglx
 
 #DRI_DIRS = ffb gamma sis savage tdfx unichrome fb
-DRI_DIRS = i810 i915tex i915 mach64 mga r128 r200 radeon
+DRI_DIRS = i965
diff -Naur mesa-14-08-2009/src/glx/mini/Makefile mesa/src/glx/mini/Makefile
--- mesa-14-08-2009/src/glx/mini/Makefile	2009-08-19 16:00:50.000000000 +0200
+++ mesa/src/glx/mini/Makefile	2009-08-18 19:02:59.000000000 +0200
@@ -46,12 +46,14 @@
 
 default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/miniglx.conf
 
+CORE_MESA = $(TOP)/src/mesa/libmesa.a $(TOP)/src/mesa/libglapi.a
+#CORE_MEDA = 
 
 # Make libGL
 $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME):  $(OBJECTS) Makefile
 	@ $(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
 		-major 1 -minor 2 $(MKLIB_OPTIONS) \
-		-install $(TOP)/$(LIB_DIR) $(GL_LIB_DEPS) $(OBJECTS) \
+		-install $(TOP)/$(LIB_DIR) $(GL_LIB_DEPS) $(OBJECTS) $(CORE_MESA) \
 		$(LIBDRM_LIB) $(PCIACCESS_LIB)
 
 
diff -Naur mesa-14-08-2009/src/glx/mini/miniglx.c mesa/src/glx/mini/miniglx.c
--- mesa-14-08-2009/src/glx/mini/miniglx.c	2009-08-19 16:00:50.000000000 +0200
+++ mesa/src/glx/mini/miniglx.c	2009-08-24 17:01:52.000000000 +0200
@@ -110,6 +110,7 @@
 
 #include "miniglxP.h"
 #include "dri_util.h"
+#include "utils.h"
 
 #include "imports.h"
 #include "glcontextmodes.h"
@@ -117,7 +118,13 @@
 
 #include "pciaccess.h"
 
-static GLboolean __glXCreateContextWithConfig(__DRInativeDisplay *dpy,
+typedef void __DRInativeDisplay;
+typedef unsigned long __DRIid;
+typedef void (*__DRIfuncPtr)(void); 
+typedef struct __DRIinterfaceMethodsRec  __DRIinterfaceMethods;
+
+static GLboolean __glXCreateContextWithConfig(
+	__DRInativeDisplay *dpy,
         int screen, int fbconfigID, void *contextID,
         drm_context_t *hHWContext);
 
@@ -137,16 +144,68 @@
 static GLboolean __glXGetMscRate(__DRInativeDisplay * dpy, __DRIid drawable,
     int32_t * numerator, int32_t * denominator);
 
+static GLboolean
+__driGetMscRateONL(__DRIdrawable * draw,
+                   int32_t * numerator, int32_t * denominator, void *private)
+{
+	return __glXGetMscRate(NULL, 0, numerator, denominator);
+};
+
 static GLboolean xf86DRI_DestroyContext(__DRInativeDisplay *dpy, int screen,
     __DRIid context_id );
 
 static GLboolean xf86DRI_CreateDrawable(__DRInativeDisplay *dpy, int screen,
     __DRIid drawable, drm_drawable_t *hHWDrawable );
-
+	
 static GLboolean xf86DRI_DestroyDrawable(__DRInativeDisplay *dpy, int screen,
     __DRIid drawable);
 
 
+const __DRIsystemTimeExtension systemTimeExtension = {
+   {__DRI_SYSTEM_TIME, __DRI_SYSTEM_TIME_VERSION},
+   __glXGetUST,
+   __driGetMscRateONL
+};
+
+static GLboolean
+__glXDRIGetDrawableInfo(__DRIdrawable * drawable,
+                        unsigned int *index, unsigned int *stamp,
+                        int *X, int *Y, int *W, int *H,
+                        int *numClipRects, drm_clip_rect_t ** pClipRects,
+                        int *backX, int *backY,
+                        int *numBackClipRects,
+                        drm_clip_rect_t ** pBackClipRects,
+                        void *loaderPrivate)
+{
+	Display *dpy = NULL;
+	// get dpy
+	int screen = 0;
+	// get screen
+	GLXDrawable draw;
+	// get GLXDrawable
+	return __glXGetDrawableInfo(dpy, screen, (__DRIid) draw, index, stamp,
+		X,Y,W,H,
+		numClipRects, pClipRects, 
+		backX, backY,
+		numBackClipRects,
+		pBackClipRects);
+	
+};
+
+
+
+static const __DRIgetDrawableInfoExtension getDrawableInfoExtension = {
+   {__DRI_GET_DRAWABLE_INFO, __DRI_GET_DRAWABLE_INFO_VERSION},
+   __glXDRIGetDrawableInfo
+};
+
+static const __DRIextension *loader_extensions[] = {
+   &systemTimeExtension.base,
+//   &getDrawableInfoExtension.base,
+   NULL
+};
+
+
 /** Wrapper around either malloc() */
 void *
 _mesa_malloc(size_t bytes)
@@ -976,7 +1035,8 @@
  * \todo
  * Create a macro or something so that this is automatically updated.
  */
-static const char createNewScreenName[] = "__driCreateNewScreen_20050727";
+//static const char createNewScreenName[] = "__driCreateNewScreen_20050727";
+static const char createNewScreenName[] = "driCreateNewScreen";
 
 
 static int InitDriver( Display *dpy )
@@ -1002,14 +1062,20 @@
               dpy->clientDriverName);
       goto failed;
    }
+  
+   dpy->core = (__DRIcoreExtension *) dlsym(dpy->dlHandle,
+					  	"driCoreExtension");
+   if (!dpy->core) {
+      fprintf(stderr, "Couldn't find driCoreExtension in %s\n",
+		dpy->clientDriverName);
+      goto failed;
+   }
 
-   /* Pull in standard DRI client-side driver hooks:
-    */
-   dpy->createNewScreen = (PFNCREATENEWSCREENFUNC)
-           dlsym(dpy->dlHandle, createNewScreenName);
-   if (!dpy->createNewScreen) {
-      fprintf(stderr, "Couldn't find %s in %s\n", createNewScreenName,
-              dpy->clientDriverName);
+   dpy->legacy = (__DRIlegacyExtension *) dlsym(dpy->dlHandle,
+					  	"driLegacyExtension");
+   if (!dpy->legacy) {
+      fprintf(stderr, "Couldn't find driLegacyExtension in %s\n",
+		dpy->clientDriverName);
       goto failed;
    }
 
@@ -1098,6 +1164,7 @@
     */
    if (!SetupFBDev(dpy)) {
       fprintf(stderr, "SetupFBDev failed\n");
+      dpy->driver->haltFBDev( &dpy->driverContext);
       free(dpy);
       return NULL;
    }
@@ -1132,6 +1199,110 @@
     return NULL;
 }
 
+struct __DRIinterfaceMethodsRec {
+    /**
+     * Get pointer to named function.
+     */
+    __DRIfuncPtr (*getProcAddress)( const char * proc_name );
+
+    /**
+     * Create a list of \c __GLcontextModes structures.
+     */
+    __GLcontextModes * (*createContextModes)(unsigned count,
+        size_t minimum_bytes_per_struct);
+
+    /**
+     * Destroy a list of \c __GLcontextModes structures.
+     *
+     * \todo
+     * Determine if the drivers actually need to call this.
+     */
+    void (*destroyContextModes)( __GLcontextModes * modes );
+
+    /**
+     * Get the \c __DRIscreen for a given display and screen number.
+     */
+    __DRIscreen *(*getScreen)(__DRInativeDisplay *dpy, int screenNum);
+
+
+    /**
+     * \name Client/server protocol functions.
+     *
+     * These functions implement the DRI client/server protocol for
+     * context and drawable operations.  Platforms that do not implement
+     * the wire protocol (e.g., EGL) will implement glorified no-op functions.
+     */
+    /*@{*/
+    /**
+     * Determine if the specified window ID still exists.
+     *
+     * \note
+     * Implementations may assume that the driver will only pass an ID into
+     * this function that actually corresponds to a window.  On
+     * implementations where windows can only be destroyed by the DRI driver
+     * (e.g., EGL), this function is allowed to always return \c GL_TRUE.
+     */
+    GLboolean (*windowExists)(__DRInativeDisplay *dpy, __DRIid draw);
+
+    /**
+     * Create the server-side portion of the GL context.
+     */
+    GLboolean (* createContext)( __DRInativeDisplay *dpy, int screenNum,
+        int configID, void * contextID, drm_context_t * hw_context );
+
+    /**
+     * Destroy the server-side portion of the GL context.
+     */
+    GLboolean (* destroyContext)( __DRInativeDisplay *dpy, int screenNum,
+        __DRIid context );
+
+    /**
+     * Create the server-side portion of the drawable.
+     */
+    GLboolean (*createDrawable)( __DRInativeDisplay * ndpy, int screen,
+        __DRIid drawable, drm_drawable_t * hHWDrawable );
+
+    /**
+     * Destroy the server-side portion of the drawable.
+     */
+    GLboolean (*destroyDrawable)( __DRInativeDisplay * ndpy, int screen,
+        __DRIid drawable );
+    /**
+     * This function is used to get information about the position, size, and
+     * clip rects of a drawable.
+     */
+    GLboolean (* getDrawableInfo) ( __DRInativeDisplay *dpy, int scrn,
+        __DRIid draw, unsigned int * index, unsigned int * stamp,
+        int * x, int * y, int * width, int * height,
+        int * numClipRects, drm_clip_rect_t ** pClipRects,
+        int * backX, int * backY,
+        int * numBackClipRects, drm_clip_rect_t ** pBackClipRects );
+    /*@}*/
+
+
+    /**
+     * \name Timing related functions.
+     */
+    /*@{*/
+    /**
+     * Get the 64-bit unadjusted system time (UST).
+     */
+    int (*getUST)(int64_t * ust);
+
+    /**
+     * Get the media stream counter (MSC) rate.
+     *
+     * Matching the definition in GLX_OML_sync_control, this function returns
+     * the rate of the "media stream counter".  In practical terms, this is
+     * the frame refresh rate of the display.
+     */
+    GLboolean (*getMSCRate)(__DRInativeDisplay * dpy, __DRIid drawable,
+        int32_t * numerator, int32_t * denominator);
+    /*@}*/
+};
+
+
+
 
 /**
  * Table of functions exported by the loader to the driver.
@@ -1156,11 +1327,9 @@
     __glXGetMscRate,
 };
 
-
-static void *
+static void * 
 CallCreateNewScreen(Display *dpy, int scrn, __DRIscreen *psc)
 {
-    void *psp = NULL;
     drm_handle_t hSAREA;
     drmAddress pSAREA;
     const char *BusID;
@@ -1267,32 +1436,39 @@
     if ( status == 0 ) {
         err_msg = "InitDriver";
         err_extra = NULL;
-        psp = dpy->createNewScreen(dpy, scrn, psc, NULL,
+        psc = dpy->legacy->createNewScreen(scrn,
                 & ddx_version,
                 & dri_version,
                 & drm_version,
                 & framebuffer,
                 pSAREA,
                 fd,
-                20050727,
-		& interface_methods,
-                (__GLcontextModes **) &dpy->driver_modes);
+		loader_extensions,
+                &dpy->driver_modes,
+		NULL);
 
 	/* fill in dummy visual ids */
 	{
+	  int x;
+
+	  for (x=0; dpy->driver_modes[x]; x++) {
+
 	  __GLcontextModes *temp;
-	  temp = (__GLcontextModes *)dpy->driver_modes;
+  	  const __GLcontextModes modes = dpy->driver_modes[x]->modes;
+	  temp = (__GLcontextModes *)&modes;
 	  i = 1;
 	  while (temp)
 	  {
 	    temp->visualID = i++;
 	    temp=temp->next;
 	  }
+
+	  }
 	}
     }
     
 done:
-    if ( psp == NULL ) {
+    if ( psc == NULL ) {
         if ( pSAREA != MAP_FAILED ) {
             (void)drmUnmap(pSAREA, SAREA_MAX);
         }
@@ -1319,8 +1495,7 @@
 
         fprintf(stderr, "libGL error: reverting to (slow) indirect rendering\n");
     }
-
-    return psp;
+    return psc;
 }
 
 /**
@@ -1388,8 +1563,8 @@
     *
     * Need to shut down DRM and free DRI data in XDestroyWindow(), too.
     */
-   dpy->driScreen.private = CallCreateNewScreen(dpy, 0, &dpy->driScreen);
-   if (!dpy->driScreen.private) {
+   void *psc = CallCreateNewScreen(dpy, 0, &dpy->driScreen);
+   if (!psc) {
       fprintf(stderr, "%s: __driCreateScreen failed\n", __FUNCTION__);
       dlclose(dpy->dlHandle);
       free(dpy);
@@ -1428,7 +1603,7 @@
 
    /* As this is done in XOpenDisplay, need to undo it here:
     */
-   dpy->driScreen.destroyScreen(dpy, 0, dpy->driScreen.private);
+   dpy->core->destroyScreen(&dpy->driScreen);
 
    __miniglx_close_connections( dpy );
 
@@ -1492,7 +1667,6 @@
                XSetWindowAttributes *attributes )
 {
    const int empty_attribute_list[1] = { None };
-
    Window win;
 
    /* ignored */
@@ -1558,14 +1732,18 @@
       win->curBottom = win->frontBottom;
    }
 
-   dpy->driScreen.createNewDrawable(dpy, visual->mode, (int) win,
-           &win->driDrawable, GLX_WINDOW_BIT, empty_attribute_list);
+   drm_drawable_t hwDrawable;
+   xf86DRI_CreateDrawable(dpy, 0, (__DRIid)0, &hwDrawable);
+
+   __DRIdrawable *draw = dpy->legacy->createNewDrawable(&dpy->driScreen, visual->driConfig, hwDrawable,
+            GLX_WINDOW_BIT, empty_attribute_list, NULL);
 
-   if (!win->driDrawable.private) {
+   if (!draw) {
       fprintf(stderr, "%s: dri.createDrawable failed\n", __FUNCTION__);
       free(win);
       return NULL;
    }
+   win->driDrawable = *draw;
 
    dpy->NumWindows++;
    dpy->TheWindow = win;
@@ -1598,7 +1776,7 @@
       XUnmapWindow( display, win );
 
       /* Destroy the drawable. */
-      win->driDrawable.destroyDrawable(display, win->driDrawable.private);
+      display->core->destroyDrawable(&win->driDrawable);
       free(win);
       
       /* unlink window from display */
@@ -1705,16 +1883,18 @@
    const __GLcontextModes *mode;
    XVisualInfo *results;
    Visual *visResults;
-   int i, n=0;
+   int i, n=0,x;
 
    //   ASSERT(vinfo_mask == VisualScreenMask);
    ASSERT(vinfo_template.screen == 0);
 
    if (vinfo_mask == VisualIDMask)
    {
-     for ( mode = dpy->driver_modes ; mode != NULL ; mode= mode->next )
+	for (x=0; dpy->driver_modes[x]; x++) {
+     for ( mode = &(dpy->driver_modes[x]->modes) ; mode != NULL ; mode= mode->next )
        if (mode->visualID == vinfo_template->visualid)
 	 n=1;
+}
 
      if (n==0)
        return NULL;
@@ -1732,7 +1912,8 @@
        return NULL;
      }
 
-     for ( mode = dpy->driver_modes ; mode != NULL ; mode= mode->next )
+     for (x=0; dpy->driver_modes[x]; x++) {
+     for ( mode = &dpy->driver_modes[x]->modes ; mode != NULL ; mode= mode->next )
        if (mode->visualID == vinfo_template->visualid)
        {
 	 visResults[0].mode=mode;
@@ -1757,13 +1938,15 @@
 	 results[0].bits_per_rgb = dpy->driverContext.bpp;
 	 
        }
-     
+     }
    }
    else // if (vinfo_mask == VisualScreenMask)
    {
      n = 0;
-     for ( mode = dpy->driver_modes ; mode != NULL ; mode = mode->next )
+     for (x=0; dpy->driver_modes[x]; x++) {
+     for ( mode = &dpy->driver_modes[x]->modes ; mode != NULL ; mode = mode->next )
        n++;
+     }
      
      results = (XVisualInfo *)calloc(1, n * sizeof(XVisualInfo));
      if (!results) {
@@ -1778,7 +1961,8 @@
        return NULL;
      }
      
-     for ( mode = dpy->driver_modes, i = 0 ; mode != NULL ; mode = mode->next, i++ ) {
+     for (x=0; dpy->driver_modes[x]; x++) {
+     for ( mode = &dpy->driver_modes[x]->modes, i = 0 ; mode != NULL ; mode = mode->next, i++ ) {
        visResults[i].mode = mode;
        visResults[i].visInfo = results + i;
        visResults[i].dpy = dpy;
@@ -1801,6 +1985,7 @@
 	 mode->redBits;
        results[i].bits_per_rgb = dpy->driverContext.bpp;
      }
+     }
    }
    *nitens_return = n;
    return results;
@@ -1862,6 +2047,7 @@
 glXChooseVisual( Display *dpy, int screen, int *attribList )
 {
    const __GLcontextModes *mode;
+   const __DRIconfig *config;
    Visual *vis;
    XVisualInfo *visInfo;
    const int *attrib;
@@ -1870,6 +2056,7 @@
    GLint indexBits = 0, depthBits = 0, stencilBits = 0;
    GLint numSamples = 0;
    int i=0;
+   int x;
 
    /*
     * XXX in the future, <screen> might be interpreted as a VT
@@ -1962,7 +2149,9 @@
    (void) blueBits;
    (void) alphaBits;
    (void) stereoFlag;
-   for ( mode = dpy->driver_modes ; mode != NULL ; mode = mode->next ) {
+   for (x=0; dpy->driver_modes[x]; x++) {
+	 config = dpy->driver_modes[x];
+     for ( mode = &(config->modes); mode != NULL ; mode = mode->next ) {
      i++;
       if (mode->rgbMode == rgbFlag &&
           mode->doubleBufferMode == dbFlag &&
@@ -1975,9 +2164,11 @@
          /* found it */
          visInfo->visualid = i;
          vis->mode = mode;
+	 vis->driConfig = config;
          break;
       }          
    }
+   }
    if (!vis->mode)
        return NULL;
 
@@ -2100,7 +2291,7 @@
                         GLXContext shareList, Bool direct )
 {
    GLXContext ctx;
-   void *sharePriv;
+   __DRIcontext *sharePriv;
 
    ASSERT(vis);
 
@@ -2109,21 +2300,33 @@
       return NULL;
 
    ctx->vid = vis->visualid;
+
  
    if (shareList)
-      sharePriv = shareList->driContext.private;
+      sharePriv = &shareList->driContext;
    else
       sharePriv = NULL;
-  
-   ctx->driContext.mode = vis->visual->mode;
-   ctx->driContext.private = dpy->driScreen.createNewContext(dpy, vis->visual->mode,
-           GLX_WINDOW_BIT, sharePriv, &ctx->driContext);
+ 
+   __DRIcontext *context;
+
+   drm_context_t hwContext;
+   int contextId;
+
+   if (__glXCreateContextWithConfig(dpy, 0, 0, &contextId, &hwContext)) {
+	free(ctx);
+	return NULL;
+   }
+ 
+   context = dpy->legacy->createNewContext(&dpy->driScreen, vis->visual->driConfig,
+           vis->visual->mode->renderType, sharePriv, hwContext, NULL);
 
-   if (!ctx->driContext.private) {
+   if (!context) {
       free(ctx);
       return NULL;
    }
 
+  ctx->driContext = *context;
+
    return ctx;
 }
 
@@ -2146,10 +2349,10 @@
    if (ctx) {
       if (glxctx == ctx) {
          /* destroying current context */
-         ctx->driContext.bindContext(dpy, 0, 0, 0, 0);
+         dpy->core->bindContext(&ctx->driContext, 0, 0);
 	 CurrentContext = 0;
       }
-      ctx->driContext.destroyContext(dpy, 0, ctx->driContext.private);
+      dpy->core->destroyContext(&ctx->driContext);
       free(ctx);
    }
 }
@@ -2184,25 +2387,25 @@
 Bool
 glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx)
 {
+
    if (dpy && drawable && ctx) {
       GLXContext oldContext = glXGetCurrentContext();
       GLXDrawable oldDrawable = glXGetCurrentDrawable();
       /* unbind old */
       if (oldContext) {
-         oldContext->driContext.unbindContext(dpy, 0,
-                 (__DRIid) oldDrawable, (__DRIid) oldDrawable,
+         dpy->core->unbindContext(
                  &oldContext->driContext);
       }
       /* bind new */
       CurrentContext = ctx;
-      ctx->driContext.bindContext(dpy, 0, (__DRIid) drawable,
-              (__DRIid) drawable, &ctx->driContext);
+      dpy->core->bindContext(&ctx->driContext,&(drawable->driDrawable),
+              &(drawable->driDrawable));
       ctx->drawBuffer = drawable;
       ctx->curBuffer = drawable;
    }
    else if (ctx && dpy) {
       /* unbind */
-      ctx->driContext.bindContext(dpy, 0, 0, 0, 0);
+      dpy->core->bindContext(&ctx->driContext, 0, 0);
    }
    else if (dpy) {
       CurrentContext = 0;	/* kw:  this seems to be intended??? */
@@ -2232,7 +2435,7 @@
    if (!dpy || !drawable)
       return;
 
-   drawable->driDrawable.swapBuffers(dpy, drawable->driDrawable.private);
+   dpy->core->swapBuffers(&drawable->driDrawable);
 }
 
 
@@ -2311,8 +2514,6 @@
     drm_clip_rect_t * cliprect;
     Display* display = (Display*)dpy;
     __DRIscreenPrivate *psp = display->driScreen.private;
-    __DRIcontextPrivate *pcp = (__DRIcontextPrivate *)CurrentContext->driContext.private;
-    __DRIdrawablePrivate *pdp = pcp->driDrawablePriv;
     if (drawable == 0) {
         return GL_FALSE;
     }
@@ -2326,8 +2527,8 @@
     /* the drawable index is by client id */
     *index = display->clientID;
 
-    *stamp = pcp->driScreenPriv->pSAREA->drawableTable[display->clientID].stamp;
-    drmUpdateDrawableInfo(psp->fd, pdp->hHWDrawable, DRM_DRAWABLE_CLIPRECTS, 1, cliprect);
+    *stamp = drawable->driDrawable.driScreenPriv->pSAREA->drawableTable[display->clientID].stamp;
+    drmUpdateDrawableInfo(psp->fd, drawable->driDrawable.hHWDrawable, DRM_DRAWABLE_CLIPRECTS, 1, cliprect);
     *x = drawable->x;
     *y = drawable->y;
     *width = drawable->w;
@@ -2361,7 +2562,7 @@
   int ret;
   ret = drmCreateDrawable(psp->fd, hHWDrawable);
   
-  fprintf(stderr, "drawable is %d %08X ret is %d\n", *hHWDrawable, drawable, -ret);
+  fprintf(stderr, "drawable is %d %08X ret is %d\n", *hHWDrawable, (unsigned int)drawable, -ret);
   if (ret != 0)
     return GL_FALSE;
   return GL_TRUE;
@@ -2508,28 +2709,28 @@
                             size_t size, float readFreq,
                             float writeFreq, float priority)
 {
-    if (dpy->driScreen.private && dpy->driScreen.allocateMemory) {
+    /*if (dpy->driScreen.private && dpy->driScreen.allocateMemory) {
 	return (*dpy->driScreen.allocateMemory)( dpy, scrn, size,
 						 readFreq, writeFreq,
 						 priority );
-    }
+    }*/
 
     return NULL;
 }
 
 void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer)
 {
-    if (dpy->driScreen.private && dpy->driScreen.freeMemory) {
+    /*if (dpy->driScreen.private && dpy->driScreen.freeMemory) {
 	(*dpy->driScreen.freeMemory)( dpy, scrn, pointer );
-    }
+    }*/
 }
 
 GLuint glXGetMemoryOffsetMESA( Display *dpy, int scrn,
                                const void *pointer )
 {
-    if (dpy->driScreen.private && dpy->driScreen.memoryOffset) {
+    /*if (dpy->driScreen.private && dpy->driScreen.memoryOffset) {
 	return (*dpy->driScreen.memoryOffset)( dpy, scrn, pointer );
-    }
+    }*/
 
     return 0;
 }
diff -Naur mesa-14-08-2009/src/glx/mini/miniglxP.h mesa/src/glx/mini/miniglxP.h
--- mesa-14-08-2009/src/glx/mini/miniglxP.h	2009-08-19 16:00:50.000000000 +0200
+++ mesa/src/glx/mini/miniglxP.h	2009-08-20 23:51:33.000000000 +0200
@@ -19,6 +19,18 @@
 
 #include "driver.h"
 #include "GL/internal/dri_interface.h"
+#include "dri_util.h"
+
+typedef  __DRIscreen *
+( *PFNCREATENEWSCREENFUNC )(int scrn,
+                   const __DRIversion *ddx_version,
+                   const __DRIversion *dri_version,
+                   const __DRIversion *drm_version,
+                   const __DRIframebuffer *frame_buffer,
+                   drmAddress pSAREA, int fd,
+                   const __DRIextension **extensions,
+                   const __DRIconfig ***driver_modes,
+                   void *loaderPrivate);
 
 /**
  * \brief Supported pixel formats.
@@ -39,6 +51,7 @@
 struct MiniGLXVisualRec {
    /** \brief GLX visual information */
    const __GLcontextModes *mode;
+   const __DRIconfig *driConfig; 
 
    /** \brief pointer back to corresponding ::XVisualInfo */
    XVisualInfo *visInfo;               
@@ -153,14 +166,13 @@
     * Visuals (configs) in this screen.
     */
    /*@{*/
-   const __GLcontextModes *driver_modes; /**< \brief Modes filtered by driver. */
+   const __DRIconfig **driver_modes; /**< \brief Modes filtered by driver. */
    /*@}*/
     
    /**
    * \name From __GLXdisplayPrivate
    */
    /*@{*/
-   PFNCREATENEWSCREENFUNC createNewScreen; /**< \brief \e __driCreateScreen hook */
    __DRIscreen driScreen;         /**< \brief Screen dependent methods */
    void *dlHandle;                /**<
 				   * \brief handle to the client dynamic
@@ -168,6 +180,9 @@
 				   */
    /*@}*/
 
+   __DRIcoreExtension *core;
+   __DRIlegacyExtension *legacy;
+
    /**
     * \brief Mini GLX specific driver hooks
     */
diff -Naur mesa-14-08-2009/src/mesa/drivers/dri/Makefile.template mesa/src/mesa/drivers/dri/Makefile.template
--- mesa-14-08-2009/src/mesa/drivers/dri/Makefile.template	2009-08-19 16:00:50.000000000 +0200
+++ mesa/src/mesa/drivers/dri/Makefile.template	2009-08-18 19:07:46.000000000 +0200
@@ -60,7 +60,7 @@
 
 ##### TARGETS #####
 
-default: symlinks depend $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME)
+default: symlinks $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME)
 
 
 $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template
diff -Naur mesa-14-08-2009/src/mesa/drivers/dri/i965/Makefile mesa/src/mesa/drivers/dri/i965/Makefile
--- mesa-14-08-2009/src/mesa/drivers/dri/i965/Makefile	2009-08-19 16:00:50.000000000 +0200
+++ mesa/src/mesa/drivers/dri/i965/Makefile	2009-08-18 19:09:52.000000000 +0200
@@ -85,7 +85,8 @@
 	brw_wm_pass2.c \
 	brw_wm_sampler_state.c \
 	brw_wm_state.c \
-	brw_wm_surface_state.c 
+	brw_wm_surface_state.c \
+	intel_dri.c
 
 C_SOURCES = \
 	$(COMMON_SOURCES) \
diff -Naur mesa-14-08-2009/src/mesa/drivers/dri/intel/server/intel_dri.c mesa/src/mesa/drivers/dri/intel/server/intel_dri.c
--- mesa-14-08-2009/src/mesa/drivers/dri/intel/server/intel_dri.c	2009-08-19 16:00:50.000000000 +0200
+++ mesa/src/mesa/drivers/dri/intel/server/intel_dri.c	2009-08-24 17:36:25.000000000 +0200
@@ -35,6 +35,33 @@
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <drm/i915_drm.h>
+
+#define INLINE __inline__
+#define drmI830Sarea drm_i915_sarea_t
+#define drmI830Init drm_i915_init_t 
+#define drmI830SetParam drm_i915_setparam_t
+
+#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
+#if defined(__linux__)
+#include <byteswap.h>
+#define CPU_TO_LE32( x )        bswap_32( x )
+#elif defined(__APPLE__)
+#include <CoreFoundation/CFByteOrder.h>
+#define CPU_TO_LE32( x )        CFSwapInt32HostToLittle( x )
+#else /*__linux__ __APPLE__*/
+#include <sys/endian.h>
+#define CPU_TO_LE32( x )        bswap32( x )
+#endif /*__linux__*/
+#define MESA_BIG_ENDIAN 1
+#else
+#define CPU_TO_LE32( x )        ( x )
+#define MESA_LITTLE_ENDIAN 1
+#endif
+#define LE32_TO_CPU( x )        CPU_TO_LE32( x )
+
 
 #include "driver.h"
 #include "drm.h"
@@ -407,6 +434,10 @@
   return 1;
 }
 
+static void AgpRelease(const DRIDriverContext *ctx) {
+	drmAgpRelease(ctx->drmFD);
+}
+
 /*
  * Allocate memory from the given pool.  Grow the pool if needed and if
  * possible.
@@ -648,13 +679,13 @@
   unsigned long aperStart = ROUND_TO(pI830->aper_size - KB(32768), GTT_PAGE_SIZE) / GTT_PAGE_SIZE;
 
   fprintf(stderr, "aper size is %08X\n", ctx->shared.fbSize);
-  if (drmMMInit(ctx->drmFD, aperStart, aperEnd - aperStart, DRM_BO_MEM_TT)) {
+  /*if (drmMMInit(ctx->drmFD, aperStart, aperEnd - aperStart, DRM_BO_MEM_TT)) {
       fprintf(stderr,
 	      "DRM MM Initialization Failed\n");
   } else {
     fprintf(stderr,
 	    "DRM MM Initialized at offset 0x%lx length %d page\n", aperStart, aperEnd-aperStart);
-  }
+  }*/
 
 }
 
@@ -664,9 +695,9 @@
    drmI830Init info;
 
    memset(&info, 0, sizeof(drmI830Init));
-   info.func = I830_CLEANUP_DMA;
+   info.func = I915_CLEANUP_DMA;
 
-   if (drmCommandWrite(ctx->drmFD, DRM_I830_INIT,
+   if (drmCommandWrite(ctx->drmFD, DRM_I915_INIT,
 		       &info, sizeof(drmI830Init))) {
      fprintf(stderr, "I830 Dma Cleanup Failed\n");
       return FALSE;
@@ -682,7 +713,7 @@
    drmI830Init info;
 
    memset(&info, 0, sizeof(drmI830Init));
-   info.func = I830_INIT_DMA;
+   info.func = I915_INIT_DMA;
 
    info.ring_start = ring->mem.Start + pI830->LinearAddr;
    info.ring_end = ring->mem.End + pI830->LinearAddr;
@@ -702,7 +733,7 @@
    info.depth_pitch = pI830->DepthBuffer.Pitch;
    info.cpp = ctx->cpp;
 
-   if (drmCommandWrite(ctx->drmFD, DRM_I830_INIT,
+   if (drmCommandWrite(ctx->drmFD, DRM_I915_INIT,
 		       &info, sizeof(drmI830Init))) {
       fprintf(stderr,
 		 "I830 Dma Initialization Failed\n");
@@ -806,7 +837,7 @@
    sp.param = param;
    sp.value = value;
 
-   if (drmCommandWrite(ctx->drmFD, DRM_I830_SETPARAM, &sp, sizeof(sp))) {
+   if (drmCommandWrite(ctx->drmFD, DRM_I915_SETPARAM, &sp, sizeof(sp))) {
       fprintf(stderr, "I830 SetParam Failed\n");
       return FALSE;
    }
@@ -921,7 +952,7 @@
 
    if (ctx->pciDevice != PCI_CHIP_845_G &&
        ctx->pciDevice != PCI_CHIP_I830_M) {
-      I830SetParam(ctx, I830_SETPARAM_USE_MI_BATCHBUFFER_START, 1 );
+      I830SetParam(ctx, I915_SETPARAM_USE_MI_BATCHBUFFER_START, 1 );
    }
 
    /* Okay now initialize the dma engine */
@@ -1142,10 +1173,33 @@
 
    pI830DRI->bitsPerPixel = ctx->bpp;
    pI830DRI->sarea_priv_offset = sizeof(drm_sarea_t);
+  
+   err = drmSetMaster(ctx->drmFD);
+   if (err) {
+       fprintf(stderr, "drmSetMaster failed");
+       AgpRelease(ctx);
+       return FALSE;
+   } 
+   drm_magic_t magic;
+   err = drmGetMagic(ctx->drmFD, &magic);   
+   if (err) {
+       fprintf(stderr, "drmGetMagic failed");
+       AgpRelease(ctx);
+       return FALSE;
+   }
    
+   err = drmAuthMagic(ctx->drmFD, magic);
+   if (err) {
+       fprintf(stderr, "drmAuthMagic failed");
+       AgpRelease(ctx);
+       return FALSE;
+   } 
+
    err = I830DRIDoMappings(ctx, pI830, pSAREAPriv);
-   if (err == FALSE)
+   if (err == FALSE) {
+       AgpRelease(ctx);
        return FALSE;
+   }
 
    I830SetupMemoryTiling(ctx, pI830);
 
@@ -1275,6 +1329,7 @@
 
   I830DRIUnmapScreenRegions(ctx, pI830, pSAREAPriv);
   drmUnmap( ctx->pSAREA, ctx->shared.SAREASize );
+  drmDropMaster(ctx->drmFD);
   drmClose(ctx->drmFD);
   
   if (ctx->driverPrivate) {
diff -Naur mesa-14-08-2009/src/mesa/glapi/glapioffsets.h mesa/src/mesa/glapi/glapioffsets.h
--- mesa-14-08-2009/src/mesa/glapi/glapioffsets.h	2009-08-19 16:00:51.000000000 +0200
+++ mesa/src/mesa/glapi/glapioffsets.h	2009-08-18 17:25:46.000000000 +0200
@@ -816,6 +816,7 @@
 #define _gloffset_FIRST_DYNAMIC 781
 
 #else
+#define _gloffset_FIRST_DYNAMIC 781
 
 #define _gloffset_AttachShader driDispatchRemapTable[AttachShader_remap_index]
 #define _gloffset_CreateProgram driDispatchRemapTable[CreateProgram_remap_index]
diff -Naur mesa-14-08-2009/src/mesa/glapi/glprocs.h mesa/src/mesa/glapi/glprocs.h
--- mesa-14-08-2009/src/mesa/glapi/glprocs.h	2009-08-19 16:00:51.000000000 +0200
+++ mesa/src/mesa/glapi/glprocs.h	2009-08-18 17:23:54.000000000 +0200
@@ -49,8 +49,6 @@
 #  define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , (_glapi_proc) f3 , o }
 #endif
 
-
-
 static const char gl_string_table[] =
     "glNewList\0"
     "glEndList\0"
@@ -1644,6 +1642,7 @@
     NAME_FUNC_OFFSET( 5704, glMultiTexCoord4ivARB, glMultiTexCoord4ivARB, NULL, _gloffset_MultiTexCoord4ivARB),
     NAME_FUNC_OFFSET( 5726, glMultiTexCoord4sARB, glMultiTexCoord4sARB, NULL, _gloffset_MultiTexCoord4sARB),
     NAME_FUNC_OFFSET( 5747, glMultiTexCoord4svARB, glMultiTexCoord4svARB, NULL, _gloffset_MultiTexCoord4svARB),
+#ifndef IN_DRI_DRIVER
     NAME_FUNC_OFFSET( 5769, glAttachShader, glAttachShader, NULL, _gloffset_AttachShader),
     NAME_FUNC_OFFSET( 5784, glCreateProgram, glCreateProgram, NULL, _gloffset_CreateProgram),
     NAME_FUNC_OFFSET( 5800, glCreateShader, glCreateShader, NULL, _gloffset_CreateShader),
@@ -2317,7 +2316,7 @@
     NAME_FUNC_OFFSET(19442, glRenderbufferStorageEXT, glRenderbufferStorageEXT, NULL, _gloffset_RenderbufferStorageEXT),
     NAME_FUNC_OFFSET(19464, gl_dispatch_stub_773, gl_dispatch_stub_773, NULL, _gloffset_BlitFramebufferEXT),
     NAME_FUNC_OFFSET(19482, glFramebufferTextureLayerEXT, glFramebufferTextureLayerEXT, NULL, _gloffset_FramebufferTextureLayerEXT),
+#endif
     NAME_FUNC_OFFSET(-1, NULL, NULL, NULL, 0)
 };
-
 #undef NAME_FUNC_OFFSET
