head	1.6;
access;
symbols
	mesa-3-1-with-kw3:1.2
	mesa-3-1-prior-to-kw3:1.1;
locks; strict;
comment	@ * @;


1.6
date	99.05.02.00.59.25;	author keithw;	state dead;
branches;
next	1.5;

1.5
date	99.03.31.20.18.42;	author keithw;	state Exp;
branches;
next	1.4;

1.4
date	99.03.30.02.42.40;	author brianp;	state Exp;
branches;
next	1.3;

1.3
date	99.02.25.19.13.57;	author davidb;	state Exp;
branches;
next	1.2;

1.2
date	99.02.25.14.12.33;	author keithw;	state Exp;
branches;
next	1.1;

1.1
date	99.02.24.03.46.00;	author brianp;	state Exp;
branches;
next	;


desc
@@


1.6
log
@FX polygon offset and debugging changes
@
text
@/* -*- mode: C; tab-width:8;  -*-

             fxtris.c - 3Dfx VooDoo triangle functions 
*/

/*
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * See the file fxapi.c for more informations about authors
 *
 */

#if defined(FX)

#include "fxdrv.h"
#include "../mmath.h"


/************************************************************************/
/*********************** Triangle functions *****************************/
/************************************************************************/


/************************************************************************/

void fxTriangleSmooth(GLcontext *ctx, GLuint v1, GLuint v2, GLuint v3, GLuint pv)
{
   GrVertex *gWin = (GrVertex *)ctx->VB->driver_data;

  grDrawTriangle(&gWin[v1], &gWin[v2], &gWin[v3]);
}

static void fxTriangleSmoothTwoSide(GLcontext *ctx, GLuint v1, GLuint v2, GLuint v3, GLuint pv)
{
   struct vertex_buffer *VB=ctx->VB;
   GrVertex *gWin = (GrVertex *) VB->driver_data;

  GOURAUD(v1); 
  GOURAUD(v2); 
  GOURAUD(v3); 

  grDrawTriangle(&gWin[v1], &gWin[v2], &gWin[v3]);
}

static void fxTriangleFlat(GLcontext *ctx, GLuint v1, GLuint v2, GLuint v3, GLuint pv)
{
  fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
  GrVertex *gWin = (GrVertex *)ctx->VB->driver_data;

  FX_VB_COLOR(fxMesa, ctx->VB->ColorPtr->data[pv]);

  grDrawTriangle(&gWin[v1], &gWin[v2], &gWin[v3]);
}

/************************************************************************/

static void fxTriangleSmoothFrontBack(GLcontext *ctx, GLuint v1,
				      GLuint v2, GLuint v3, GLuint pv)
{
  fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
  GrVertex *gWin = (GrVertex *)ctx->VB->driver_data;

  grColorMask(ctx->Color.ColorMask[RCOMP] ||
	      ctx->Color.ColorMask[GCOMP] ||
	      ctx->Color.ColorMask[BCOMP],
	      FXFALSE);

  grDepthMask(FXFALSE);
  grRenderBuffer(GR_BUFFER_BACKBUFFER);
  grDrawTriangle(&gWin[v1], &gWin[v2], &gWin[v3]);

  grColorMask(ctx->Color.ColorMask[RCOMP] ||
	      ctx->Color.ColorMask[GCOMP] ||
	      ctx->Color.ColorMask[BCOMP],
	      ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); 
  if(ctx->Depth.Mask)
    grDepthMask(FXTRUE);
  grRenderBuffer(GR_BUFFER_FRONTBUFFER);
  grDrawTriangle(&gWin[v1], &gWin[v2], &gWin[v3]);
}

static void fxTriangleSmoothTwoSideFrontBack(GLcontext *ctx, GLuint v1,
					     GLuint v2, GLuint v3, GLuint pv)
{
  fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
  struct vertex_buffer *VB=ctx->VB;
  GrVertex *gWin = (GrVertex *) VB->driver_data;

  GOURAUD(v1); 
  GOURAUD(v2); 
  GOURAUD(v3); 

  grColorMask(ctx->Color.ColorMask[RCOMP] ||
	      ctx->Color.ColorMask[GCOMP] ||
	      ctx->Color.ColorMask[BCOMP],
	      FXFALSE);
  grDepthMask(FXFALSE);
  grRenderBuffer(GR_BUFFER_BACKBUFFER);
  grDrawTriangle(&gWin[v1], &gWin[v2], &gWin[v3]);

 /
			sprintf(modname, "binfmt-%hd", *(short*)(&bprm->buf));
			request_module(modname);
#endif
		}
	}
	return retval;
}


/*
 * sys_execve() executes a new program.
 */
int do_execve(char * filename, char ** argv, char ** envp, struct pt_regs * regs)
{
	struct linux_binprm bprm;
	int retval;
	int i;

	bprm.p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
	for (i=0 ; i<MAX_ARG_PAGES ; i++)	/* clear page-table */
		bprm.page[i] = 0;
	retval = open_namei(filename, 0, 0, &bprm.inode, NULL);
	if (retval)
		return retval;
	bprm.filename = filename;
	bprm.sh_bang = 0;
	bprm.loader = 0;
	bprm.exec = 0;
	bprm.dont_iput = 0;
	if ((bprm.argc = count(argv)) < 0)
		return bprm.argc;
	if ((bprm.envc = count(envp)) < 0)
		return bprm.envc;

	retval = prepare_binprm(&bprm);
	
	if(retval>=0) {
		bprm.p = copy_strings(1, &bprm.filename, bprm.page, bprm.p, 2);
		bprm.exec = bprm.p;
		bprm.p = copy_strings(bprm.envc,envp,bprm.page,bprm.p,0);
		bprm.p = copy_strings(bprm.argc,argv,bprm.page,bprm.p,0);
		if (!bprm.p)
			retval = -E2BIG;
	}

	if(retval>=0)
		retval = search_binary_handler(&bprm,regs);
	if(retval>=0)
		/* execve success */
		return retval;

	/* Something went wrong, return the inode and free the argument pages*/
	if(!bprm.dont_iput)
		iput(bprm.inode);
	for (i=0 ; i<MAX_ARG_PAGES ; i++)
		free_page(bprm.page[i]);
	return(retval);
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  /*
 *  linux/fs/super.c
 *
 *  Copyright (C) 1991, 1992  Linus Torvalds
 *
 *  super.c contains code to handle: - mount structures
 *                                   - super-block tables.
 *                                   - mount systemcall
 *                                   - umount systemcall
 *
 *  Added options to /proc/mounts
 *  Torbjörn Lindh (torbjorn.lindh@gopta.se), April 14, 1996.
 *
 * GK 2/5/95  -  Changed to support mounting the root fs via NFS
 *
 *  Added kerneld support: Jacques Gelinas and Bjorn Ekwall
 *  Added change_root: Werner Almesberger & Hans Lermen, Feb '96
 */

#include <stdarg.h>

#include <linux/config.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/mount.h>
#include <linux/malloc.h>
#include <linux/major.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/locks.h>
#include <linux/mm.h>
#include <linux/fd.h>

#include <asm/system.h>
#include <asm/segment.h>
#include <asm/bitops.h>

#ifdef CONFIG_KERNELD
#include <linux/kerneld.h>
#endif
 
#include <linux/nfs_fs.h>
#include <linux/nfs_fs_sb.h>
#include <linux/nfs_mount.h>

extern void wait_for_keypress(void);
extern struct file_operations * get_blkfops(unsigned int major);
extern void blkdev_release (struct inode *);
extern void rd_load_secondary(void);

extern int root_mountflags;

static int do_remount_sb(struct super_block *sb, int flags, char * data);

/* this is initialized in init/main.c */
kdev_t ROOT_DEV;

struct super_block super_blocks[NR_SUPER];
static struct file_system_type *file_systems = (struct file_system_type *) NULL;
static struct vfsmount *vfsmntlist = (struct vfsmount *) NULL,
                       *vfsmnttail = (struct vfsmount *) NULL,
                       *mru_vfsmnt = (struct vfsmount *) NULL;

/* 
 * This part handles the management of the list of mounted filesystems.
 */
struct vfsmount *lookup_vfsmnt(kdev_t dev)
{
	struct vfsmount *lptr;

	if (vfsmntlist == (struct vfsmount *)NULL)
		return ((struct vfsmount *)NULL);

	if (mru_vfsmnt != (struct vfsmount *)NULL &&
	    mru_vfsmnt->mnt_dev == dev)
		return (mru_vfsmnt);

	for (lptr = vfsmntlist;
	     lptr != (struct vfsmount *)NULL;
	     lptr = lptr->mnt_next)
		if (lptr->mnt_dev == dev) {
			mru_vfsmnt = lptr;
			return (lptr);
		}

	return ((struct vfsmount *)NULL);
	/* NOTREACHED */
}

struct vfsmount *add_vfsmnt(kdev_t dev, const char *dev_name, const char *dir_name)
{
	struct vfsmount *lptr;
	char *tmp;

	lptr = (struct vfsmount *)kmalloc(sizeof(struct vfsmount), GFP_KERNEL);
        if (!lptr)
		return NULL;
	memset(lptr, 0, sizeof(struct vfsmount));

	lptr->mnt_dev = dev;
	lptr->mnt_sem.count = 1;
	if (dev_name && !getname(dev_name, &tmp)) {
		if ((lptr->mnt_devname =
		    (char *) kmalloc(strlen(tmp)+1, GFP_KERNEL)) != (char *)NULL)
			strcpy(lptr->mnt_devname, tmp);
		putname(tmp);
	}
	if (dir_name && !getname(dir_name, &tmp)) {
		if ((lptr->mnt_dirname =
		    (char *) kmalloc(strlen(tmp)+1, GFP_KERNEL)) != (char *)NULL)
			strcpy(lptr->mnt_dirname, tmp);
		putname(tmp);
	}

	if (vfsmntlist == (struct vfsmount *)NULL) {
		vfsmntlist = vfsmnttail = lptr;
	} else {
		vfsmnttail->mnt_next = lptr;
		vfsmnttail = lptr;
	}
	return (lptr);
}

void remove_vfsmnt(kdev_t dev)
{
	struct vfsmount *lptr, *tofree;

	if (vfsmntlist == (struct vfsmount *)NULL)
		return;
	lptr = vfsmntlist;
	if (lptr->mnt_dev == dev) {
		tofree = lptr;
		vfsmntlist = lptr->mnt_next;
		if (vfsmnttail->mnt_dev == dev)
			vfsmnttail = vfsmntlist;
	} else {
		while (lptr->mnt_next != (struct vfsmount *)NULL) {
			if (lptr->mnt_next->mnt_dev == dev)
				break;
			lptr = lptr->mnt_next;
		}
		tofree = lptr->mnt_next;
		if (tofree == (struct vfsmount *)NULL)
			return;
		lptr->mnt_next = lptr->mnt_next->mnt_next;
		if (vfsmnttail->mnt_dev == dev)
			vfsmnttail = lptr;
	}
	if (tofree == mru_vfsmnt)
		mru_vfsmnt = NULL;
	kfree(tofree->mnt_devname);
	kfree(tofree->mnt_dirname);
	kfree_s(tofree, sizeof(struct vfsmount));
}

int register_filesystem(struct file_system_type * fs)
{
        struct file_system_type ** tmp;

        if (!fs)
                return -EINVAL;
        if (fs->next)
                return -EBUSY;
        tmp = &file_systems;
        while (*tmp) {
                if (strcmp((*tmp)->name, fs->name) == 0)
                        return -EBUSY;
                tmp = &(*tmp)->next;
        }
        *tmp = fs;
        return 0;
}

#ifdef CONFIG_MODULES
int unregister_filesystem(struct file_system_type * fs)
{
	struct file_system_type ** tmp;

	tmp = &file_systems;
	while (*tmp) {
		if (fs == *tmp) {
			*tmp = fs->next;
			fs->next = NULL;
			return 0;
		}
		tmp = &(*tmp)->next;
	}
	return -EINVAL;
}
#endif

static int fs_index(const char * __name)
{
	struct file_system_type * tmp;
	char * name;
	int err, index;

	err = getname(__name, &name);
	if (err)
		return err;
	index = 0;
	for (tmp = file_systems ; tmp ; tmp = tmp->next) {
		if (strcmp(tmp->name, name) == 0) {
			putname(name);
			return index;
		}
		index++;
	}
	putname(name);
	return -EINVAL;
}

static int fs_name(unsigned int index, char * buf)
{
	struct file_system_type * tmp;
	int err, len;

	tmp = file_systems;
	while (tmp && index > 0) {
		tmp = tmp->next;
		index--;
	}
	if (!tmp)
		return -EINVAL;
	len = strlen(tmp->name) + 1;
	err = verify_area(VERIFY_WRITE, buf, len);
	if (err)
		return err;
	memcpy_tofs(buf, tmp->name, len);
	return 0;
}

static int fs_maxindex(void)
{
	struct file_system_