Revert "r300: Gracefully exit after GART memory is exhausted."
[mesa.git] / src / mesa / drivers / ggi / default / genkgi_mode.c
index 81cf6c840712830695ed4e2cde4eeb030000bafb..938024789f999cc669a419191f7cae4f55833eb0 100644 (file)
@@ -1,9 +1,9 @@
-/* $Id: genkgi_mode.c,v 1.1 1999/08/21 05:59:29 jtaylor Exp $
+/* $Id: genkgi_mode.c,v 1.4 2000/01/07 08:34:44 jtaylor Exp $
 ******************************************************************************
 
    display-fbdev-kgicon-generic-mesa
 
-   Copyright (C) 1999 Creative Labs
+   Copyright (C) 1999 Jon Taylor [taylorj@ggi-project.org]
 
    Permission is hereby granted, free of charge, to any person obtaining a
    copy of this software and associated documentation files (the "Software"),
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 
-//#include <linux/fb.h>
-
 #include <ggi/internal/ggi-dl.h>
 #include <ggi/mesa/ggimesa_int.h>
+#include <ggi/mesa/debug.h>
 #include "genkgi.h"
 
 int GGIMesa_genkgi_getapi(ggi_visual *vis, int num, char *apiname, char *arguments)
 {
-       genkgi_hook_mesa *priv = GENKGI_PRIVATE(vis);
+       struct genkgi_priv_mesa *priv = GENKGI_PRIV_MESA(vis);
        
-       gl_ggiDEBUG("Entered mesa_genkgi_getapi, num=%d\n", num);
+       GGIMESADPRINT_CORE("Entered mesa_genkgi_getapi, num=%d\n", num);
        
        strcpy(arguments, "");
 
@@ -59,3 +58,40 @@ int GGIMesa_genkgi_getapi(ggi_visual *vis, int num, char *apiname, char *argumen
        }
        return -1;
 }
+
+int GGIMesa_genkgi_flush(ggi_visual *vis, int x, int y, int w, int h, int tryflag)
+{
+       struct genkgi_priv_mesa *priv = GENKGI_PRIV_MESA(vis);
+       int junkval; 
+
+       priv->oldpriv->kgicommand_ptr += getpagesize(); 
+       (kgiu32)(priv->oldpriv->kgicommand_ptr) &= 0xfffff000;
+       junkval = *((int *)(priv->oldpriv->kgicommand_ptr));
+       
+       /* Check if we are now in the last page, and reset the
+        * FIFO if so.  We can't use the last page to send
+        * more commands, since there's no page after it that
+        * we can touch to fault in the last page's commands.
+        * 
+        * FIXME: This will be replaced with a flush-and-reset handler
+        * on the end-of-buffer pagefault at some point....
+        * 
+        */
+       if ((priv->oldpriv->kgicommand_ptr - priv->oldpriv->mapped_kgicommand)
+           >= (priv->oldpriv->kgicommand_buffersize - getpagesize()))
+       {
+               munmap(priv->oldpriv->mapped_kgicommand, priv->oldpriv->kgicommand_buffersize);
+               if ((priv->oldpriv->mapped_kgicommand = 
+                    mmap(NULL, 
+                         priv->oldpriv->kgicommand_buffersize, 
+                         PROT_READ | PROT_WRITE,
+                         MAP_SHARED,
+                         priv->oldpriv->fd_kgicommand, 
+                         0)) == MAP_FAILED)
+               {
+                       ggiPanic("Failed to remap kgicommand!");
+               }
+               priv->oldpriv->kgicommand_ptr = priv->oldpriv->mapped_kgicommand;
+       }
+       return 0;
+}