git-svn-id: svn://kolibrios.org@877 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-10-13 21:02:35 +00:00
parent 037ab747c1
commit fb3e9a2b66
25 changed files with 731 additions and 5999 deletions

View File

@ -1,15 +1,15 @@
#define FILL_RECT 1
#define DRAW_RECT 2
#define LINE_2P 3
#define BLIT 4
#define COMPIZ 5
#define PX_CREATE 6
#define PIXBLIT 7
#define PIXLOCK 8
#define PIXUNLOCK 9
#define PIXDESTROY 10
#define TRANSBLIT 11
#define PX_CREATE 1
#define PX_DESTROY 2
#define PX_DRAW_RECT 3
#define PX_FILL_RECT 4
#define PX_LINE 5
#define PX_BLIT 6
#define PX_BLIT_TRANSPARENT 7
#define PX_BLIT_ALPHA 8
//#define BLIT 4
//#define COMPIZ 5
typedef unsigned int color_t;

View File

@ -1,4 +1,72 @@
int Line(draw_t *draw)
{
local_pixmap_t *dstpixmap;
clip_t clip;
int x0, y0, x1, y1;
dstpixmap = (draw->dstpix == (void*)-1) ? &scr_pixmap : draw->dstpix ;
x0 = draw->x0;
y0 = draw->y0;
x1 = draw->x1;
y1 = draw->y1;
clip.xmin = 0;
clip.ymin = 0;
clip.xmax = dstpixmap->width-1;
clip.ymax = dstpixmap->height-1;
if ( !LineClip(&clip, &x0, &y0, &x1, &y1 ))
{
u32_t efl;
u32_t *ring, write;
efl = safe_cli();
#if R300_PIO
R5xxFIFOWait(6);
OUTREG(R5XX_DP_GUI_MASTER_CNTL,
rhd.gui_control |
R5XX_GMC_BRUSH_SOLID_COLOR |
R5XX_GMC_SRC_DATATYPE_COLOR |
R5XX_GMC_CLR_CMP_CNTL_DIS |
R5XX_GMC_WR_MSK_DIS |
R5XX_ROP3_P
);
OUTREG(R5XX_DST_LINE_PATCOUNT, 0x55 << R5XX_BRES_CNTL_SHIFT);
OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->color);
OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset);
OUTREG(R5XX_DST_LINE_START,(y0<<16)|x0);
OUTREG(R5XX_DST_LINE_END,(y1<<16)|x1);
#else
BEGIN_RING();
OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_POLYLINE, 4));
OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL |
RADEON_GMC_BRUSH_SOLID_COLOR |
RADEON_GMC_DST_32BPP |
RADEON_GMC_SRC_DATATYPE_COLOR |
R5XX_GMC_CLR_CMP_CNTL_DIS |
R5XX_GMC_WR_MSK_DIS |
R5XX_ROP3_P);
OUT_RING(dstpixmap->pitch_offset);
OUT_RING(draw->color);
OUT_RING((y0<<16)|x0);
OUT_RING((y1<<16)|x1);
COMMIT_RING();
#endif
safe_sti(efl);
};
return ERR_OK;
}
int DrawRect(draw_t* draw)
{
@ -215,170 +283,8 @@ int Blit(blit_t *blit)
return ERR_OK;
}
int Line2P(draw_t *draw)
{
local_pixmap_t *dstpixmap;
int x0, y0, x1, y1;
dstpixmap = (draw->dstpix == (void*)-1) ? &scr_pixmap : draw->dstpix ;
x0 = draw->x0;
y0 = draw->y0;
x1 = draw->x1;
y1 = draw->y1;
if ( !LineClip(&clip, &x0, &y0, &x1, &y1 ))
{
u32 efl;
u32 *ring, write;
efl = safe_cli();
#if R300_PIO
R5xxFIFOWait(6);
OUTREG(R5XX_DP_GUI_MASTER_CNTL,
rhd.gui_control |
R5XX_GMC_BRUSH_SOLID_COLOR |
R5XX_GMC_SRC_DATATYPE_COLOR |
R5XX_GMC_CLR_CMP_CNTL_DIS |
R5XX_GMC_WR_MSK_DIS |
R5XX_ROP3_P
);
OUTREG(R5XX_DST_LINE_PATCOUNT, 0x55 << R5XX_BRES_CNTL_SHIFT);
OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->color);
OUTREG(R5XX_DST_PITCH_OFFSET, rhd.dst_pitch_offset);
OUTREG(R5XX_DST_LINE_START,(y0<<16)|x0);
OUTREG(R5XX_DST_LINE_END,(y1<<16)|x1);
#else
BEGIN_RING();
OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_POLYLINE, 4));
OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL |
RADEON_GMC_BRUSH_SOLID_COLOR |
RADEON_GMC_DST_32BPP |
RADEON_GMC_SRC_DATATYPE_COLOR |
R5XX_GMC_CLR_CMP_CNTL_DIS |
R5XX_GMC_WR_MSK_DIS |
R5XX_ROP3_P);
OUT_RING(rhd.dst_pitch_offset);
OUT_RING(draw->color);
OUT_RING((y0<<16)|x0);
OUT_RING((y1<<16)|x1);
COMMIT_RING();
#endif
safe_sti(efl);
};
return ERR_OK;
}
#endif
int CreatePixmap(pixmap_t *io)
{
local_pixmap_t *pixmap;
unsigned pitch;
size_t size;
void *local;
if( (io->width == 0) || (io->width > 2048)||
(io->height == 0)|| (io->height > 2048))
{
dbgprintf("Invalid pixmap size w:%d h:%d\n", io->width,io->height);
return ERR_PARAM;
};
pitch = ((io->width+15)&~15)*4;
size = pitch*io->height;
dbgprintf("pitch = %d\n", pitch);
local = rhd_mem_alloc(&rhd,RHD_MEM_FB,size) ;
if ( !local)
{
dbgprintf("Not enough memory for pixmap\n");
return ERR_PARAM;
};
pixmap = malloc(sizeof(local_pixmap_t));
if(!pixmap)
{
rhd_mem_free(&rhd, RHD_MEM_FB,local);
return ERR_PARAM;
}
else
{
void *mapped;
size = (size+4095) & ~ 4095;
if (mapped = UserAlloc(size))
{
CommitPages(mapped, ((u32_t)local+rhd.PhisBase)|7|(1<<9), size);
io->mapped = mapped;
io->pitch = pitch;
io->handle = (u32_t)pixmap;
pixmap->width = io->width;
pixmap->height = io->height;
pixmap->format = PICT_a8r8g8b8;
pixmap->flags = io->flags;
pixmap->pitch = pitch;
pixmap->mapped = mapped;
pixmap->pitch_offset = ((pitch/64)<<22)| (((u32_t)local+rhd.FbIntAddress)>>10);
pixmap->local = local;
dbgprintf("pixmap.pitch_offset: %x\n", pixmap->pitch_offset);
dbgprintf("width: %d height: %d\n",pixmap->width,pixmap->height );
dbgprintf("map at %x\n", pixmap->mapped);
return ERR_OK;
};
rhd_mem_free(&rhd, RHD_MEM_FB,local);
free(pixmap);
};
return ERR_PARAM;
};
int DestroyPixmap( pixmap_t *io )
{
local_pixmap_t *pixmap;
size_t size;
dbgprintf("Destroy pixmap %x\n", io->handle);
if(io->handle == -1)
return ERR_PARAM;
else
pixmap = (local_pixmap_t*)io->handle;
size = (pixmap->pitch*pixmap->height+4095) & ~ 4095;
UnmapPages(pixmap->mapped, size);
UserFree(pixmap->mapped);
rhd_mem_free(&rhd,RHD_MEM_FB,pixmap->local);
free(pixmap);
io->format = 0;
io->pitch = 0;
io->mapped = NULL;
io->handle = 0;
return ERR_OK;
};
#if 0

View File

@ -59,7 +59,7 @@ static void Init3DEngine(RHDPtr rhdPtr)
u32_t gb_tile_config, su_reg_dest, vap_cntl;
// ACCEL_PREAMBLE();
u32 *ring, write;
u32_t *ring, write;
// info->texW[0] = info->texH[0] = info->texW[1] = info->texH[1] = 1;
@ -1098,7 +1098,7 @@ static void RadeonCompositeTile(int srcX, int srcY,
xPointFixed srcTopLeft, srcTopRight, srcBottomLeft, srcBottomRight;
xPointFixed maskTopLeft, maskTopRight, maskBottomLeft, maskBottomRight;
u32 *ring, write;
u32_t *ring, write;
// ACCEL_PREAMBLE();

View File

@ -1,7 +1,11 @@
//ld -T ld.x -s --shared --image-base 0 --file-alignment 32 -o test.exe test.obj core.lib
#include "types.h"
#include "common.h"
#include <stdio.h>
#include <malloc.h>
#include <memory.h>
#include "syscall.h"
#include "ati2d.h"
#include "accel_2d.h"
@ -12,26 +16,14 @@ static clip_t clip;
static local_pixmap_t scr_pixmap;
/*
void STDCALL (*SelectHwCursor)(cursor_t*)__asm__("SelectHwCursor");
void STDCALL (*SetHwCursor)(cursor_t*,int x,int y)__asm__("SetHwCursor");
void STDCALL (*HwCursorRestore)(int x, int y)__asm("HwCursorRestore");
cursor_t* IMPORT (*HwCursorCreate)(void)__asm("HwCursorCreate"); //params eax, ebx, ecx
void (__stdcall *old_select)(cursor_t*);
void (__stdcall *old_set)(cursor_t*,int x,int y);
void (__stdcall *old_restore)(int x, int y);
cursor_t* (*old_create)(void);
cursor_t* __create_cursor(void);
*/
static void Init3DEngine(RHDPtr rhdPtr);
u32 __stdcall drvEntry(int action)
int __stdcall srv_2d(ioctl_t *io);
u32_t __stdcall drvEntry(int action)
{
RHDPtr rhdPtr;
u32 retval;
u32_t retval;
int i;
@ -65,26 +57,17 @@ u32 __stdcall drvEntry(int action)
if(!RHDPreInit())
return 0;
// old_select = SelectHwCursor;
// old_set = SetHwCursor;
// old_restore = HwCursorRestore ;
// old_create = HwCursorCreate;
R5xx2DInit();
rhd.has_tcl = 1;
// Init3DEngine(&rhd);
//init_r500();
// SelectHwCursor = r500_SelectCursor;
// SetHwCursor = r500_SetCursor;
// HwCursorCreate = __create_cursor;
// HwCursorRestore = r500_CursorRestore;
retval = RegService("HDRAW", srv_2d);
dbgprintf("reg service %s as: %x\n", "HDRAW", retval);
// retval = RegService("HWCURSOR", srv_cursor);
return retval;
};
@ -93,36 +76,11 @@ u32 __stdcall drvEntry(int action)
#define SRV_GETVERSION 0
/*
int _stdcall srv_cursor(ioctl_t *io)
{
u32 *inp;
u32 *outp;
inp = io->input;
outp = io->output;
switch(io->io_code)
{
case SRV_GETVERSION:
if(io->out_size==4)
{
*(u32*)io->output = API_VERSION;
return 0;
}
break;
default:
return ERR_PARAM;
};
return ERR_PARAM;
}
*/
int _stdcall srv_2d(ioctl_t *io)
{
u32 *inp;
u32 *outp;
u32_t *inp;
u32_t *outp;
inp = io->input;
outp = io->output;
@ -137,21 +95,42 @@ int _stdcall srv_2d(ioctl_t *io)
}
break;
case DRAW_RECT:
case PX_CREATE:
if(io->inp_size==7)
return CreatePixmap((pixmap_t*)inp);
break;
case PX_DESTROY:
if(io->inp_size==7)
return DestroyPixmap((pixmap_t*)inp);
break;
case PX_DRAW_RECT:
if(io->inp_size==6)
return DrawRect((draw_t*)inp);
break;
case FILL_RECT:
case PX_FILL_RECT:
if(io->inp_size==9)
return FillRect((fill_t*)inp);
break;
/*
case LINE_2P:
if(io->inp_size==6)
return Line2P((draw_t*)inp);
case PX_BLIT:
if(io->inp_size==8)
return PixBlit((pixblit_t*)inp);
break;
case PX_BLIT_TRANSPARENT:
if(io->inp_size==8)
return TransBlit((pixblit_t*)inp);
break;
case PX_LINE:
if(io->inp_size==6)
return Line((draw_t*)inp);
break;
/*
case BLIT:
if(io->inp_size==6)
return Blit((blit_t*)inp);
@ -162,36 +141,6 @@ int _stdcall srv_2d(ioctl_t *io)
return RadeonComposite((blit_t*)inp);
break;
*/
case PX_CREATE:
if(io->inp_size==7)
return CreatePixmap((pixmap_t*)inp);
break;
case PIXBLIT:
if(io->inp_size==8)
return PixBlit((pixblit_t*)inp);
break;
// case PIXLOCK:
// if(io->inp_size==6)
// return LockPixmap((userpixmap_t*)inp);
// break;
// case PIXUNLOCK:
// if(io->inp_size==6)
// return UnlockPixmap((userpixmap_t*)inp);
// break;
case PIXDESTROY:
if(io->inp_size==6)
return DestroyPixmap((pixmap_t*)inp);
break;
case TRANSBLIT:
if(io->inp_size==8)
return TransBlit((pixblit_t*)inp);
break;
default:
return ERR_PARAM;
@ -208,6 +157,7 @@ int _stdcall srv_2d(ioctl_t *io)
#include "r500.inc"
#include "clip.inc"
#include "pixmap.inc"
#include "accel_2d.inc"
#include "accel_3d.inc"

View File

@ -1,4 +1,13 @@
typedef void *pointer;
typedef unsigned int Bool;
typedef unsigned int memType;
typedef struct { float hi, lo; } range;
#include "pci.h"
#include "rhd_regs.h"
@ -105,17 +114,17 @@ enum RHD_FAMILIES {
typedef struct RHDRec
{
CARD32 MMIOBase;
CARD32 MMIOMapSize;
CARD32 videoRam;
u32_t MMIOBase;
u32_t MMIOMapSize;
u32_t videoRam;
// CARD32 FbBase; /* map base of fb */
CARD32 PhisBase;
CARD32 FbIntAddress; /* card internal address of FB */
CARD32 FbMapSize;
u32_t PhisBase;
u32_t FbIntAddress; /* card internal address of FB */
u32_t FbMapSize;
CARD32 FbFreeStart;
CARD32 FbFreeSize;
u32_t FbFreeStart;
u32_t FbFreeSize;
/* visible part of the framebuffer */
unsigned int FbScanoutStart;
@ -128,38 +137,38 @@ typedef struct RHDRec
Bool IsIGP;
CARD32 bus;
CARD32 devfn;
u32_t bus;
u32_t devfn;
PCITAG PciTag;
CARD16 PciDeviceID;
u16_t PciDeviceID;
CARD16 subvendor_id;
CARD16 subdevice_id;
u16_t subvendor_id;
u16_t subdevice_id;
CARD32 memBase[6];
CARD32 ioBase[6];
CARD32 memtype[6];
CARD32 memsize[6];
u32_t memBase[6];
u32_t ioBase[6];
u32_t memtype[6];
u32_t memsize[6];
struct mem_block *fb_heap;
struct mem_block *gart_heap;
CARD32 displayWidth;
CARD32 displayHeight;
u32_t displayWidth;
u32_t displayHeight;
CARD32 __xmin;
CARD32 __ymin;
CARD32 __xmax;
CARD32 __ymax;
int __xmin;
int __ymin;
int __xmax;
int __ymax;
CARD32 gui_control;
CARD32 dst_pitch_offset;
CARD32 surface_cntl;
u32_t gui_control;
u32_t dst_pitch_offset;
u32_t surface_cntl;
u32 *ring_base;
u32 ring_rp;
u32 ring_wp;
u32_t *ring_base;
u32_t ring_rp;
u32_t ring_wp;
int num_gb_pipes;
Bool has_tcl;
@ -253,34 +262,34 @@ typedef struct {
extern inline void
OUTREG8(CARD16 offset, u8 value)
OUTREG8(u16_t offset, u8_t value)
{
*(volatile CARD8 *)((CARD8 *)(rhd.MMIOBase + offset)) = value;
*(volatile u8_t *)((u8_t *)(rhd.MMIOBase + offset)) = value;
}
extern inline CARD32 INREG(CARD16 offset)
extern inline u32_t INREG(u16_t offset)
{
return *(volatile CARD32 *)((CARD8*)(rhd.MMIOBase + offset));
return *(volatile u32_t *)((u8_t*)(rhd.MMIOBase + offset));
}
//#define INREG(offset) *(volatile CARD32 *)((CARD8*)(rhd.MMIOBase + (offset)))
extern inline void
OUTREG(CARD16 offset, CARD32 value)
OUTREG(u16_t offset, u32_t value)
{
*(volatile CARD32 *)((CARD8 *)(rhd.MMIOBase + offset)) = value;
*(volatile u32_t *)((u8_t *)(rhd.MMIOBase + offset)) = value;
}
extern inline CARD32 _RHDRegRead(RHDPtr rhdPtr, CARD16 offset)
extern inline u32_t _RHDRegRead(RHDPtr rhdPtr, u16_t offset)
{
return *(volatile CARD32 *)((CARD8*)(rhdPtr->MMIOBase + offset));
return *(volatile u32_t *)((u8_t*)(rhdPtr->MMIOBase + offset));
}
extern inline void
MASKREG(CARD16 offset, CARD32 value, CARD32 mask)
MASKREG(u16_t offset, u32_t value, u32_t mask)
{
CARD32 tmp;
u32_t tmp;
tmp = INREG(offset);
tmp &= ~mask;
@ -289,15 +298,15 @@ MASKREG(CARD16 offset, CARD32 value, CARD32 mask)
};
extern inline void
_RHDRegWrite(RHDPtr rhdPtr, CARD16 offset, CARD32 value)
_RHDRegWrite(RHDPtr rhdPtr, u16_t offset, u32_t value)
{
*(volatile CARD32 *)((CARD8 *)(rhdPtr->MMIOBase + offset)) = value;
*(volatile u32_t *)((u8_t *)(rhdPtr->MMIOBase + offset)) = value;
}
extern inline void
_RHDRegMask(RHDPtr rhdPtr, CARD16 offset, CARD32 value, CARD32 mask)
_RHDRegMask(RHDPtr rhdPtr, u16_t offset, u32_t value, u32_t mask)
{
CARD32 tmp;
u32_t tmp;
tmp = _RHDRegRead(rhdPtr, offset);
tmp &= ~mask;
@ -325,15 +334,15 @@ int rhdInitHeap(RHDPtr rhdPtr);
#pragma pack (push,1)
typedef struct s_cursor
{
u32 magic; // 'CURS'
u32_t magic; // 'CURS'
void (*destroy)(struct s_cursor*); // destructor
u32 fd; // next object in list
u32 bk; // prev object in list
u32 pid; // owner id
u32_t fd; // next object in list
u32_t bk; // prev object in list
u32_t pid; // owner id
void *base; // allocated memory
u32 hot_x; // hotspot coords
u32 hot_y;
u32_t hot_x; // hotspot coords
u32_t hot_y;
}cursor_t;
#pragma pack (pop)
@ -341,7 +350,7 @@ typedef struct s_cursor
#define LOAD_FROM_MEM 1
#define LOAD_INDIRECT 2
cursor_t *create_cursor(u32 pid, void *src, u32 flags);
cursor_t *create_cursor(u32_t pid, void *src, u32_t flags);
void __stdcall copy_cursor(void *img, void *src);
void destroy_cursor(cursor_t *cursor);
void __destroy_cursor(cursor_t *cursor); // wrap

View File

@ -0,0 +1,181 @@
#define CLIP_TOP 1
#define CLIP_BOTTOM 2
#define CLIP_RIGHT 4
#define CLIP_LEFT 8
static int _L1OutCode( clip_t *clip, int x, int y )
/*=================================
Verify that a point is inside or outside the active viewport. */
{
int flag;
flag = 0;
if( x < clip->xmin ) {
flag |= CLIP_LEFT;
} else if( x > clip->xmax ) {
flag |= CLIP_RIGHT;
}
if( y < clip->ymin ) {
flag |= CLIP_TOP;
} else if( y > clip->ymax ) {
flag |= CLIP_BOTTOM;
}
return( flag );
}
static void line_inter( int * x1, int* y1, int x2, int y2, int x )
/*===========================================================================
Find the intersection of a line with a boundary of the viewport.
(x1, y1) is outside and ( x2, y2 ) is inside the viewport.
NOTE : the signs of denom and ( x - *x1 ) cancel out during division
so make both of them positive before rounding. */
{
int numer;
int denom;
denom = abs( x2 - *x1 );
numer = 2L * (long)( y2 - *y1 ) * abs( x - *x1 );
if( numer > 0 ) {
numer += denom; /* round to closest pixel */
} else {
numer -= denom;
}
*y1 += numer / ( denom << 1 );
*x1 = x;
}
int LineClip( clip_t *clip, int *x1, int *y1, int *x2, int *y2 )
/*=============================================================
Clips the line with end points (x1,y1) and (x2,y2) to the active
viewport using the Cohen-Sutherland clipping algorithm. Return the
clipped coordinates and a decision drawing flag. */
{
int flag1;
int flag2;
flag1 = _L1OutCode( clip, *x1, *y1 );
flag2 = _L1OutCode( clip, *x2, *y2 );
for( ;; ) {
if( flag1 & flag2 ) break; /* trivially outside */
if( flag1 == flag2 ) break; /* completely inside */
if( flag1 == 0 ) { /* first point inside */
if( flag2 & CLIP_TOP ) {
line_inter( y2, x2, *y1, *x1, clip->ymin );
} else if( flag2 & CLIP_BOTTOM ) {
line_inter( y2, x2, *y1, *x1, clip->ymax );
} else if( flag2 & CLIP_RIGHT ) {
line_inter( x2, y2, *x1, *y1, clip->xmax );
} else if( flag2 & CLIP_LEFT ) {
line_inter( x2, y2, *x1, *y1, clip->xmin );
}
flag2 = _L1OutCode( clip, *x2, *y2 );
} else { /* second point inside */
if( flag1 & CLIP_TOP ) {
line_inter( y1, x1, *y2, *x2, clip->ymin );
} else if( flag1 & CLIP_BOTTOM ) {
line_inter( y1, x1, *y2, *x2, clip->ymax );
} else if( flag1 & CLIP_RIGHT ) {
line_inter( x1, y1, *x2, *y2, clip->xmax );
} else if( flag1 & CLIP_LEFT ) {
line_inter( x1, y1, *x2, *y2, clip->xmin );
}
flag1 = _L1OutCode( clip, *x1, *y1 );
}
}
return( flag1 & flag2 );
}
static void block_inter( clip_t *clip, int *x, int *y, int flag )
/*======================================================
Find the intersection of a block with a boundary of the viewport. */
{
if( flag & CLIP_TOP ) {
*y = clip->ymin;
} else if( flag & CLIP_BOTTOM ) {
*y = clip->ymax;
} else if( flag & CLIP_RIGHT ) {
*x = clip->xmax;
} else if( flag & CLIP_LEFT ) {
*x = clip->xmin;
}
}
int BlockClip(clip_t *clip, int *x1, int *y1, int *x2, int* y2 )
/*==============================================================
Clip a block with opposite corners (x1,y1) and (x2,y2) to the
active viewport based on the Cohen-Sutherland algorithm for line
clipping. Return the clipped coordinates and a decision drawing
flag ( 0 draw : 1 don't draw ). */
{
int flag1;
int flag2;
flag1 = _L1OutCode( clip, *x1, *y1 );
flag2 = _L1OutCode( clip, *x2, *y2 );
for( ;; ) {
if( flag1 & flag2 ) break; /* trivially outside */
if( flag1 == flag2 ) break; /* completely inside */
if( flag1 == 0 ) {
block_inter( clip, x2, y2, flag2 );
flag2 = _L1OutCode( clip, *x2, *y2 );
} else {
block_inter( clip, x1, y1, flag1 );
flag1 = _L1OutCode( clip, *x1, *y1 );
}
}
return( flag1 & flag2 );
}
int blit_clip(clip_t *dst_clip,int *dst_x,int *dst_y,
clip_t *src_clip,int *src_x, int *src_y,
int *w, int *h)
{
int sx0, sy0, sx1, sy1;
sx0 = *src_x;
sy0 = *src_y;
sx1 = sx0 + *w - 1;
sy1 = sy0 + *h - 1;
if( ! BlockClip( src_clip, &sx0, &sy0, &sx1, &sy1))
{
int dx0, dy0, dx1, dy1;
dx0 = *dst_x + sx0 - *src_x;
dy0 = *dst_y + sy0 - *src_y;
dx1 = dx0 + sx1 - sx0;
dy1 = dy0 + sy1 - sy0;
if( ! BlockClip( dst_clip, &dx0, &dy0, &dx1, &dy1))
{
*w = dx1 - dx0 + 1;
*h = dy1 - dy0 + 1;
*src_x += dx0 - *dst_x;
*src_y += dy0 - *dst_y;
*dst_x = dx0;
*dst_y = dx0;
return 0;
};
return 1;
}
return 1;
};

View File

@ -1,221 +0,0 @@
#define OS_BASE 0x80000000
#include "xmd.h"
#define NULL (void*)(0)
#define FALSE 0
#define TRUE 1
typedef void *pointer;
typedef unsigned int Bool;
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned char u8_t;
typedef unsigned short u16_t;
typedef unsigned int u32_t;
typedef unsigned int memType;
typedef unsigned int size_t;
typedef struct { float hi, lo; } range;
typedef struct
{
unsigned handle;
unsigned io_code;
void *input;
int inp_size;
void *output;
int out_size;
}ioctl_t;
typedef int (_stdcall *srv_proc_t)(ioctl_t *);
#define ERR_OK 0
#define ERR_PARAM -1
u32_t __stdcall drvEntry(int)__asm__("_drvEntry");
///////////////////////////////////////////////////////////////////////////////
#define STDCALL __attribute__ ((stdcall)) __attribute__ ((dllimport))
#define IMPORT __attribute__ ((dllimport))
///////////////////////////////////////////////////////////////////////////////
#define PG_SW 0x003
#define PG_NOCACHE 0x018
void* STDCALL AllocKernelSpace(size_t size)__asm__("AllocKernelSpace");
void* STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc");
void* STDCALL UserAlloc(size_t size)__asm__("UserAlloc");
int STDCALL UserFree(void *mem)__asm__("UserFree");
int KernelFree(void *);
void* STDCALL CreateRingBuffer(size_t size, u32 map)__asm__("CreateRingBuffer");
u32 STDCALL RegService(char *name, srv_proc_t proc)__asm__("RegService");
//void *CreateObject(u32 pid, size_t size);
//void *DestroyObject(void *obj);
CARD32 STDCALL MapIoMem(CARD32 Base,CARD32 size,CARD32 flags)__asm__("MapIoMem");
static inline u32_t GetPgAddr(void *mem)
{
u32_t retval;
asm volatile (
"call *__imp__GetPgAddr \n\t"
:"=eax" (retval)
:"a" (mem)
);
return retval;
}
static inline void CommitPages(void *mem, u32_t page, u32_t size)
{
size = (size+4095) & ~4095;
asm volatile (
"call *__imp__CommitPages"
:
:"a" (page), "b"(mem),"c"(size>>12)
:"edx"
);
asm volatile (
""
:
:
:"eax","ebx","ecx"
);
}
static inline void UnmapPages(void *mem, size_t size)
{
size = (size+4095) & ~4095;
asm volatile (
"call *__imp__UnmapPages"
:
:"a" (mem), "c"(size>>12)
:"edx"
);
asm volatile ("":::"eax","ecx");
}
///////////////////////////////////////////////////////////////////////////////
u32 PciApi(int cmd);
u8 STDCALL PciRead8 (u32 bus, u32 devfn, u32 reg)__asm__("PciRead8");
u16 STDCALL PciRead16(u32 bus, u32 devfn, u32 reg)__asm__("PciRead16");
u32 STDCALL PciRead32(u32 bus, u32 devfn, u32 reg)__asm__("PciRead32");
u32 STDCALL PciWrite8 (u32 bus, u32 devfn, u32 reg,u8 val) __asm__("PciWrite8");
u32 STDCALL PciWrite16(u32 bus, u32 devfn, u32 reg,u16 val)__asm__("PciWrite16");
u32 STDCALL PciWrite32(u32 bus, u32 devfn, u32 reg,u32 val)__asm__("PciWrite32");
///////////////////////////////////////////////////////////////////////////////
#define SysMsgBoardStr __SysMsgBoardStr
#define PciApi __PciApi
//#define RegService __RegService
#define CreateObject __CreateObject
#define DestroyObject __DestroyObject
///////////////////////////////////////////////////////////////////////////////
void *malloc(size_t);
void *calloc( size_t num, size_t size );
void *realloc(void*, size_t);
void free(void*);
#define kmalloc malloc
#define kfree free
#define xcalloc calloc
///////////////////////////////////////////////////////////////////////////////
int memcmp(const void *s1, const void *s2, size_t n);
void * memcpy(void * _dest, const void *_src, size_t _n);
char * strcpy(char *to, const char *from);
char * strcat(char *s, const char *append);
int strcmp(const char *s1, const char *s2);
size_t strlen(const char *str);
char * strdup(const char *_s);
char * strchr(const char *s, int c);
///////////////////////////////////////////////////////////////////////////////
int snprintf(char *s, size_t n, const char *format, ...);
int printf(const char* format, ...);
int dbg_open(char *path);
int dbgprintf(const char* format, ...);
///////////////////////////////////////////////////////////////////////////////
void usleep(u32 delay);
static int __attribute__ ((always_inline))
abs (int i)
{
return i < 0 ? -i : i;
};
static void __attribute__ ((always_inline))
__clear (void * dst, unsigned len)
{ u32 tmp;
asm __volatile__
(
"xorl %%eax, %%eax \n\t"
"cld \n\t"
"rep stosb \n"
:"=c"(tmp),"=D"(tmp)
:"c"(len),"D"(dst)
:"eax"
);
asm volatile ("":::"ecx","edi");
};
static inline u32 safe_cli(void)
{
u32 tmp;
asm volatile (
"pushf\n\t"
"popl %0\n\t"
"cli\n"
: "=r" (tmp)
);
return tmp;
}
static inline void safe_sti(u32 ipl)
{
asm volatile (
"pushl %0\n\t"
"popf\n"
: : "r" (ipl)
);
}
///////////////////////////////////////////////////////////////////////////////
int _stdcall srv_cursor(ioctl_t *io);
int _stdcall srv_2d(ioctl_t *io);

View File

@ -1,366 +0,0 @@
USE32
format MS COFF
include 'proc32.inc'
struc BITMAPINFOHEADER {
.biSize dd ? ; DWORD
.biWidth dd ? ; LONG
.biHeight dd ? ; LONG
.biPlanes dw ? ; WORD
.biBitCount dw ? ; WORD
.biCompression dd ? ; DWORD
.biSizeImage dd ? ; DWORD
.biXPelsPerMeter dd ? ; LONG
.biYPelsPerMeter dd ? ; LONG
.biClrUsed dd ? ; DWORD
.biClrImportant dd ? ; DWORD
}
virtual at 0
BI BITMAPINFOHEADER
end virtual
public ___create_cursor
public ___destroy_cursor
public _copy_cursor@8
extrn _create_cursor :dword
extrn _destroy_cursor :dword
extrn _tmp_cursor :dword
section 'AUTO' code readable executable align 16
align 16
___create_cursor:
push ecx
push ebx
push eax
call _create_cursor
add esp, 12
ret
align 16
___destroy_cursor:
push eax
call _destroy_cursor
add esp, 4
ret
align 16
proc _copy_cursor@8 stdcall, dst:dword, src:dword
locals
rBase dd ?
pQuad dd ?
pBits dd ?
pAnd dd ?
width dd ?
height dd ?
counter dd ?
endl
mov esi, [src]
add esi,[esi+18]
mov eax,esi
cmp [esi+BI.biBitCount], 24
je .img_24
cmp [esi+BI.biBitCount], 8
je .img_8
cmp [esi+BI.biBitCount], 4
je .img_4
.img_2:
add eax, [esi]
mov [pQuad],eax
add eax,8
mov [pBits],eax
add eax, 128
mov [pAnd],eax
mov eax,[esi+4]
mov [width],eax
mov ebx,[esi+8]
shr ebx,1
mov [height],ebx
mov edi, _tmp_cursor
add edi, 32*31*4
mov [rBase],edi
mov esi,[pQuad]
.l21:
mov ebx, [pBits]
mov ebx, [ebx]
bswap ebx
mov eax, [pAnd]
mov eax, [eax]
bswap eax
mov [counter], 32
@@:
xor edx, edx
shl eax,1
setc dl
dec edx
xor ecx, ecx
shl ebx,1
setc cl
mov ecx, [esi+ecx*4]
and ecx, edx
and edx, 0xFF000000
or edx, ecx
mov [edi], edx
add edi, 4
dec [counter]
jnz @B
add [pBits], 4
add [pAnd], 4
mov edi,[rBase]
sub edi,128
mov [rBase],edi
sub [height],1
jnz .l21
jmp .copy
.img_4:
add eax, [esi]
mov [pQuad],eax
add eax,64
mov [pBits],eax
add eax, 0x200
mov [pAnd],eax
mov eax,[esi+4]
mov [width],eax
mov ebx,[esi+8]
shr ebx,1
mov [height],ebx
mov edi, _tmp_cursor
add edi, 32*31*4
mov [rBase],edi
mov esi,[pQuad]
mov ebx, [pBits]
.l4:
mov eax, [pAnd]
mov eax, [eax]
bswap eax
mov [counter], 16
@@:
xor edx, edx
shl eax,1
setc dl
dec edx
movzx ecx, byte [ebx]
and cl, 0xF0
shr ecx, 2
mov ecx, [esi+ecx]
and ecx, edx
and edx, 0xFF000000
or edx, ecx
mov [edi], edx
xor edx, edx
shl eax,1
setc dl
dec edx
movzx ecx, byte [ebx]
and cl, 0x0F
mov ecx, [esi+ecx*4]
and ecx, edx
and edx, 0xFF000000
or edx, ecx
mov [edi+4], edx
inc ebx
add edi, 8
dec [counter]
jnz @B
add [pAnd], 4
mov edi,[rBase]
sub edi,128
mov [rBase],edi
sub [height],1
jnz .l4
jmp .copy
.img_8:
add eax, [esi]
mov [pQuad],eax
add eax,1024
mov [pBits],eax
add eax, 1024
mov [pAnd],eax
mov eax,[esi+4]
mov [width],eax
mov ebx,[esi+8]
shr ebx,1
mov [height],ebx
mov edi, _tmp_cursor
add edi, 32*31*4
mov [rBase],edi
mov esi,[pQuad]
mov ebx, [pBits]
.l81:
mov eax, [pAnd]
mov eax, [eax]
bswap eax
mov [counter], 32
@@:
xor edx, edx
shl eax,1
setc dl
dec edx
movzx ecx, byte [ebx]
mov ecx, [esi+ecx*4]
and ecx, edx
and edx, 0xFF000000
or edx, ecx
mov [edi], edx
inc ebx
add edi, 4
dec [counter]
jnz @B
add [pAnd], 4
mov edi,[rBase]
sub edi,128
mov [rBase],edi
sub [height],1
jnz .l81
jmp .copy
.img_24:
add eax, [esi]
mov [pQuad],eax
add eax, 0xC00
mov [pAnd],eax
mov eax,[esi+BI.biWidth]
mov [width],eax
mov ebx,[esi+BI.biHeight]
shr ebx,1
mov [height],ebx
mov edi, _tmp_cursor
add edi, 32*31*4
mov [rBase],edi
mov esi,[pAnd]
mov ebx, [pQuad]
.row_24:
mov eax, [esi]
bswap eax
mov [counter], 32
@@:
xor edx, edx
shl eax,1
setc dl
dec edx
mov ecx, [ebx]
and ecx, 0x00FFFFFF
and ecx, edx
and edx, 0xFF000000
or edx, ecx
mov [edi], edx
add ebx, 3
add edi, 4
dec [counter]
jnz @B
add esi, 4
mov edi,[rBase]
sub edi,128
mov [rBase],edi
sub [height],1
jnz .row_24
.copy:
mov edi, [dst]
mov ecx, 64*64
xor eax,eax
rep stosd
mov esi, _tmp_cursor
mov edi, [dst]
mov ebx, 32
cld
@@:
mov ecx, 32
rep movsd
add edi, 128
dec ebx
jnz @B
ret
endp
macro rdr op1, op2
{
mov op1, [edi+op2]
}
macro wrr dest, src
{
mov dword [edi+dest], src
}
struc CURSOR
{;common object header
.magic dd ? ;'CURS'
.destroy dd ? ;internal destructor
.fd dd ? ;next object in list
.bk dd ? ;prev object in list
.pid dd ? ;owner id
;cursor data
.base dd ? ;allocated memory
.hot_x dd ? ;hotspot coords
.hot_y dd ?
}
virtual at 0
CURSOR CURSOR
end virtual
;public _r500_SelectCursor@4
align 4
proc _r500_SelectCursor@4 stdcall,hcursor:dword
mov ecx, [hcursor]
mov edi, [_rhd]
mov edx, [ecx+CURSOR.base]
sub edx, [_rhd+3*4]
add edx, [_rhd+5*4]
mov [edi+0x6408], edx
mov eax, [ecx+CURSOR.hot_x]
shl eax, 16
mov ax, word [ecx+CURSOR.hot_y]
mov [edi+0x6418], eax
ret
endp
;public _r500_SetCursor@12
align 4
proc _r500_SetCursor@12 stdcall, hcursor:dword, x:dword, y:dword
pushfd
cli
mov edx, [_rhd]
mov eax, [x]
shl eax, 16
mov ax, word [y]
mov [edx+0x6414], eax
or dword [edx+0x6400], 1
popfd
ret
endp

View File

@ -1,103 +0,0 @@
char tmp_cursor[4096];
cursor_t *create_cursor(u32 pid, void *src, u32 flags)
{
void *img;
cursor_t *cursor = (cursor_t*)CreateObject(pid, 32);
if(cursor==NULL)
return 0;
dbgprintf("create object at %x\n", cursor);
cursor->magic = 0x53525543;
cursor->destroy = __destroy_cursor;
img = rhd_mem_alloc(&rhd,RHD_MEM_FB,64*64*4);
if(img==NULL)
goto cleanup;
dbgprintf("alloc video memory at %x size %x\n",img,64*64*4);
dbgprintf("offset %x\n", img-rhd.FbBase);
cursor->base=img;
if( (u16)flags==LOAD_INDIRECT){
cursor->hot_x = (u8)(flags>>24);
cursor->hot_y = (u8)(flags>>16);
asm __volatile__
(
"cld \n\t"
"rep stosl"
:
:"a"(0),"c"(64*64),"D"(img)
);
asm __volatile__
(
"1: "
"movl $32, %%ecx \n\t"
"rep stosl \n\t"
"addl $128, %%edi \n\t"
"decl %%ebx \n\t"
"jnz 1b"
:
:"b"(32),"S"(src),"D"(img)
);
}
else {
cursor->hot_x = *(u16*)((char*)src+10);
cursor->hot_y = *(u16*)((char*)src+12);
copy_cursor(img, src);
dbgprintf("cursor loaded\n");
}
return cursor;
cleanup:
DestroyObject(cursor);
return NULL;
};
void destroy_cursor(cursor_t *cursor)
{
if(cursor->base)
rhd_mem_free(&rhd,RHD_MEM_FB,cursor->base);
DestroyObject(cursor);
}
void __stdcall r500_SelectCursor(cursor_t *cursor)
{
CARD32 base;
base = (CARD32)cursor->base - rhd.FbBase;
asm __volatile__
(
"cli"
);
OUTREG (D1CUR_SURFACE_ADDRESS, rhd.FbIntAddress+base);
OUTREG (D1CUR_HOT_SPOT, (cursor->hot_x<<16)|(cursor->hot_y&0xFFFF));
asm __volatile__
(
"sti"
);
}
void __stdcall r500_SetCursor(cursor_t *cursor, int x, int y)
{
CARD32 tmp = (x<<16)|(y & 0xFFFF) ;
asm __volatile__
(
"pushfl \n\t"
"cli"
);
OUTREG(D1CUR_POSITION, tmp);
OUTREG(D1CUR_CONTROL, 0x301);
asm __volatile__
(
"popfl"
);
}
void __stdcall r500_CursorRestore(int x, int y)
{};

View File

@ -1,510 +0,0 @@
#include "common.h"
#pragma pack(push, 1)
typedef struct
{
char sec;
char min;
char hour;
char rsv;
}detime_t;
#pragma pack(pop)
#pragma pack(push, 1)
typedef struct
{
char day;
char month;
short year;
}dedate_t;
#pragma pack(pop)
#pragma pack(push, 1)
typedef struct
{ unsigned attr;
unsigned flags;
union
{
detime_t ctime;
unsigned cr_time;
};
union
{
dedate_t cdate;
unsigned cr_date;
};
union
{
detime_t atime;
unsigned acc_time;
};
union
{
dedate_t adate;
unsigned acc_date;
};
union
{
detime_t mtime;
unsigned mod_time;
};
union
{
dedate_t mdate;
unsigned mod_date;
};
unsigned size;
unsigned size_high;
} FILEINFO;
#pragma pack(pop)
typedef struct
{
char *path;
int offset;
} dbgfile_t;
static dbgfile_t dbgfile;
static void __SysMsgBoardStr(char *text)
{
asm __volatile__
(
"call *__imp__SysMsgBoardStr"
:
:"S" (text)
);
};
int get_fileinfo(const char *path,FILEINFO *info)
{
int retval;
asm __volatile__
(
"pushl $0 \n\t"
"pushl $0 \n\t"
"movl %%eax, 1(%%esp) \n\t"
"pushl %%ebx \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl $5 \n\t"
"movl %%esp, %%ebx \n\t"
"movl $70, %%eax \n\t"
"int $0x40 \n\t"
"addl $28, %%esp \n\t"
:"=eax" (retval)
:"a" (path), "b" (info)
);
return retval;
};
int create_file(const char *path)
{
int retval;
asm __volatile__
(
"pushl %%ebx \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"movl %%eax, 1(%%esp) \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl $2 \n\t"
"movl %%esp, %%ebx \n\t"
"movl $70, %%eax \n\t"
"int $0x40 \n\t"
"addl $28, %%esp \n\t"
"popl %%ebx"
:"=eax" (retval)
:"a" (path)
);
return retval;
};
int set_file_size(const char *path, unsigned size)
{
int retval;
asm __volatile__(
"pushl $0 \n\t"
"pushl $0 \n\t"
"movl %%eax, 1(%%esp) \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl %%ebx \n\t"
"push $4 \n\t"
"movl %%esp, %%ebx \n\t"
"movl $70, %%eax \n\t"
"int $0x40 \n\t"
"addl $28, %%esp \n\t"
:"=eax" (retval)
:"a" (path), "b" (size)
);
return retval;
};
int write_file(const char *path,const void *buff,
unsigned offset,unsigned count,unsigned *writes)
{
int retval;
asm __volatile__
(
"pushl $0 \n\t"
"pushl $0 \n\t"
"movl %%eax, 1(%%esp) \n\t"
"pushl %%ebx \n\t"
"pushl %%edx \n\t"
"pushl $0 \n\t"
"pushl %%ecx \n\t"
"pushl $3 \n\t"
"movl %%esp, %%ebx \n\t"
"mov $70, %%eax \n\t"
"int $0x40 \n\t"
"testl %%esi, %%esi \n\t"
"jz 1f \n\t"
"movl %%ebx, (%%esi) \n\t"
"1:"
"addl $28, %%esp \n\t"
:"=eax" (retval)
:"a"(path),"b"(buff),"c"(offset),"d"(count),"S"(writes)
);
return retval;
};
char * _putc(char *s, int c)
{
int i=0;
switch(c)
{
case '\n':
*s++ = '\r';
*s++ = '\n';
case '\r':
break;
case '\t':
do
{
*s++ = ' ';
}
while (i % 8 != 0);
break;
default:
*s++ = c;
}
return s;
}
char *print_string(char *buff, char* s)
{
int i=0;
char c;
while (c=*s++)
{
switch(c)
{
case '\r':
break;
case '\n':
*buff++ = '\r';
*buff++ = '\n';
i=0;
case '\t':
do
{
*buff++ = ' ';
i++;
}
while (i % 8 != 0);
break;
default:
*buff++ = c;
i++;
};
}
return buff;
}
char *print_dec(char *buff,int val)
{
char dbuff[16];
int i = 14;
dbuff[15] = '\0';
do
{
dbuff[i] = (val % 10) + '0';
val = val / 10;
i--;
} while(val);
return print_string(buff, &dbuff[i+1]);
}
const char hexchars[] = "0123456789ABCDEF";
char *print_hex(char *buff,u32 val)
{
int i;
for (i=sizeof(u32)*8-4; i >= 0; i -= 4)
buff = _putc(buff,hexchars[((u32)val >> i) & 0xF]);
return buff;
}
#define va_start(v,l) __builtin_va_start(v,l)
#define va_end(v) __builtin_va_end(v)
#define va_arg(v,l) __builtin_va_arg(v,l)
#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L
#define va_copy(d,s) __builtin_va_copy(d,s)
#endif
#define __va_copy(d,s) __builtin_va_copy(d,s)
typedef __builtin_va_list __gnuc_va_list;
typedef __gnuc_va_list va_list;
#define arg(x) va_arg (ap, u32)
char txtbuf[128];
int printf(const char* format, ...)
{
u32 ret = 1;
u32 i = 0;
char *sbuf = txtbuf;
va_list ap;
va_start (ap, format);
if (format == 0)
return 0;
while (*format)
{
switch (*(format))
{
case '%':
next_fmt:
switch (*(++format))
{
case 'l': case '-':
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
goto next_fmt;
case 'c':
sbuf = _putc (sbuf,arg (i));
break;
case 'd':
sbuf = print_dec (sbuf,arg (i));
break;
case 'p':
case 'x':
sbuf = print_hex (sbuf,(u32) arg (i));
break;
case 's':
sbuf = print_string (sbuf,(char*) arg (i));
break;
default:
sbuf = print_string (sbuf,"?");
break;
}
i++;
break;
default:
sbuf = _putc (sbuf,*format);
break;
}
format++;
}
va_end (ap);
*sbuf=0;
SysMsgBoardStr(txtbuf);
return ret;
}
int dbg_open(char *path)
{
FILEINFO info;
dbgfile.offset = 0;
if(get_fileinfo(path,&info))
{
if(!create_file(path))
{
dbgfile.path = path;
return TRUE;
}
else
return FALSE;
};
set_file_size(path, 0);
dbgfile.path = path;
dbgfile.offset = 0;
return TRUE;
};
int vsnprintf(char *s, size_t n, const char *format, va_list arg);
int dbgprintf(const char* format, ...)
{
unsigned writes;
int len=0;
// char *sbuf = txtbuf;
va_list ap;
va_start(ap, format);
if (format)
len = vsnprintf(txtbuf, 128, format, ap);
va_end(ap);
SysMsgBoardStr(txtbuf);
if(dbgfile.path)
{
write_file(dbgfile.path,txtbuf,dbgfile.offset,len,&writes);
dbgfile.offset+=writes;
};
return len;
}
int xf86DrvMsg(int skip, int code, const char* format, ...)
{
unsigned writes;
va_list ap;
int len=0;
va_start(ap, format);
if (format)
len = vsnprintf(txtbuf, 128, format, ap);
va_end(ap);
SysMsgBoardStr(txtbuf);
if(dbgfile.path)
{
write_file(dbgfile.path,txtbuf,dbgfile.offset,len,&writes);
dbgfile.offset+=writes;
};
return len;
}
int snprintf(char *s, size_t n, const char *format, ...)
{
va_list ap;
int retval;
va_start(ap, format);
retval = vsnprintf(s, n, format, ap);
va_end(ap);
return retval;
}
/*
int snprintf(char *buf,int count, const char* format, ...)
{
int len;
// u32 ret = 1;
u32 i = 0;
char *sbuf = buf;
va_list ap;
va_start (ap, format);
if (format == 0)
return 0;
while (*format)
{
switch (*(format))
{
case '%':
next_fmt:
switch (*(++format))
{
case 'l': case '-':
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
goto next_fmt;
case 'c':
sbuf = _putc (sbuf,arg (i));
break;
case 'd':
sbuf = print_dec (sbuf,arg (i));
break;
case 'p':
case 'x':
sbuf = print_hex (sbuf,(u32) arg (i));
break;
case 's':
sbuf = print_string (sbuf,(char*) arg (i));
break;
default:
sbuf = print_string (sbuf,"?");
break;
}
i++;
break;
default:
sbuf = _putc (sbuf,*format);
break;
}
format++;
}
va_end (ap);
*sbuf=0;
len = sbuf-txtbuf;
return len;
}
*/
char *
RhdAppendString(char *s1, const char *s2)
{
if (!s2)
return s1;
else
if (!s1)
return strdup(s2);
else
{
int len = strlen(s1) + strlen(s2) + 1;
char *result = (char *)kmalloc(len);
if (!result) return s1;
strcpy(result,s1);
strcat(result,s2);
kfree(s1);
return result;
}
return 0;
}

View File

@ -1,78 +0,0 @@
#include "common.h"
void usleep(u32 delay)
{
if(!delay) delay++;
delay*=2000;
asm __volatile__
(
"1:\n\t"
"xorl %%eax, %%eax \n\t"
"cpuid \n\t"
"decl %%edi \n\t"
"jnz 1b"
:
:"D"(delay)
:"eax","ebx","ecx","edx"
);
}
u32 __PciApi(int cmd)
{
u32 retval;
asm __volatile__
(
"call *__imp__PciApi"
:"=eax" (retval)
:"a" (cmd)
:"memory"
);
return retval;
};
/*
u32 __RegService(char *name, srv_proc_t proc)
{
u32 retval;
asm __volatile__
(
"pushl %%eax \n\t"
"pushl %%ebx \n\t"
"call *__imp__RegService \n\t"
:"=eax" (retval)
:"a" (proc), "b" (name)
:"memory"
);
return retval;
};
*/
void *__CreateObject(u32 pid, size_t size)
{
void *retval;
asm __volatile__
(
"call *__imp__CreateObject \n\t"
:"=eax" (retval)
:"a" (size),"b"(pid)
:"esi","edi", "memory"
);
return retval;
}
void *__DestroyObject(void *obj)
{
asm __volatile__
(
"call *__imp__DestroyObject"
:
:"a" (obj)
:"ebx","edx","esi","edi", "memory"
);
}

View File

@ -4,7 +4,7 @@ static Bool
rhdMapMMIO(RHDPtr rhdPtr)
{
rhdPtr->MMIOMapSize = 1 << rhdPtr->memsize[RHD_MMIO_BAR];
rhdPtr->MMIOBase = MapIoMem(rhdPtr->memBase[RHD_MMIO_BAR],
rhdPtr->MMIOBase = MapIoMem((void*)rhdPtr->memBase[RHD_MMIO_BAR],
rhdPtr->MMIOMapSize,PG_SW+PG_NOCACHE);
if( rhdPtr->MMIOBase==0)
return 0;
@ -15,17 +15,16 @@ rhdMapMMIO(RHDPtr rhdPtr)
#define RADEON_NB_TOM 0x15c
static CARD32
rhdGetVideoRamSize(RHDPtr rhdPtr)
static size_t rhdGetVideoRamSize(RHDPtr rhdPtr)
{
CARD32 RamSize, BARSize;
size_t RamSize, BARSize;
if (rhdPtr->ChipSet == RHD_RS690)
RamSize = (_RHDRegRead(rhdPtr, R5XX_CONFIG_MEMSIZE))>>10;
else
if (rhdPtr->IsIGP)
{
CARD32 tom = _RHDRegRead(rhdPtr, RADEON_NB_TOM);
u32_t tom = _RHDRegRead(rhdPtr, RADEON_NB_TOM);
RamSize = (((tom >> 16) - (tom & 0xffff) + 1) << 6);
_RHDRegWrite(rhdPtr,R5XX_CONFIG_MEMSIZE, RamSize<<10);
}
@ -118,9 +117,9 @@ error1:
return FALSE;
};
int KernelFree(void *p)
{
return 0;
}
//int KernelFree(void *p)
//{
//
// return 0;
//}

View File

@ -4,26 +4,22 @@ FASM = e:/fasm/fasm.exe
CFLAGS = -c -O2 -fomit-frame-pointer -fno-builtin-printf
LDRHD = -shared -T ld.x -s --file-alignment 32
HFILES:= ati2d.h \
common.h \
pci.h \
accel_2d.h \
r5xx_regs.h \
HFILES:= ati2d.h \
syscall.h \
pci.h \
accel_2d.h \
r5xx_regs.h \
microcode.h
SRC_DEP:= init.c \
pci.c \
ati_mem.c \
SRC_DEP:= init.c \
pci.c \
ati_mem.c \
r500.inc \
accel_2d.inc \
pixmap.inc \
accel_2d.inc \
accel_3d.inc
ATI_SRC:= ati2d.c \
malloc.c \
helper.c \
string.c \
dbg.c \
memset.asm
ATI_SRC:= ati2d.c
ATI_OBJ:= ati2d.obj
@ -37,7 +33,7 @@ ATI2D = ati2d.dll
all: $(ATI2D)
$(ATI2D): $(ATI_OBJ) $(SRC_DEP) $(HFILES) Makefile
wlink name ati2d.dll SYS nt_dll op offset=0 op nod op maxe=25 op el op STUB=stub.exe op START=_drvEntry @rhd.lk1
wlink name ati2d.dll SYS nt_dll lib libdrv op offset=0 op nod op maxe=25 op el op STUB=stub.exe op START=_drvEntry @rhd.lk1
kpack.exe ati2d.dll ati2d.drv
ati2d.obj : ati2d.c $(SRC_DEP) $(HFILES)

File diff suppressed because it is too large Load Diff

View File

@ -1,52 +0,0 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
##include<libc/asm.h>
# .file "memset.s"
.text
.global _memset
.align 4
_memset:
pushl %ebp
movl %esp,%ebp
pushl %edi
movl 8(%ebp),%edi
movl 12(%ebp),%eax
movl 16(%ebp),%ecx
cld
# We will handle memsets of <= 15 bytes one byte at a time.
# This avoids some extra overhead for small memsets, and
# knowing we are setting > 15 bytes eliminates some annoying
# checks in the "long move" case.
cmpl $15,%ecx
jle L3
# Otherwise, tile the byte value out into %eax.
# 0x41 -> 0x41414141, etc.
movb %al,%ah
movl %eax,%edx
sall $16,%eax
movw %dx,%ax
jmp L2
# Handle any cruft necessary to get %edi long-aligned.
L1: stosb
decl %ecx
L2: testl $3,%edi
jnz L1
# Now slam out all of the longs.
movl %ecx,%edx
shrl $2,%ecx
rep
stosl
# Finally, handle any trailing cruft. We know the high three bytes
# of %ecx must be zero, so just put the "slop count" in the low byte.
movb %dl,%cl
andb $3,%cl
L3: rep
stosb
popl %edi
movl 8(%ebp),%eax
leave
ret

View File

@ -1,5 +1,5 @@
static const u32 R300_cp_microcode[][2]={
static const u32_t R300_cp_microcode[][2]={
{ 0x4200e000, 0000000000 },
{ 0x4000e000, 0000000000 },
{ 0x000000ae, 0x00000008 },
@ -258,7 +258,7 @@ static const u32 R300_cp_microcode[][2]={
{ 0000000000, 0000000000 },
};
static const u32 R520_cp_microcode[][2]={
static const u32_t R520_cp_microcode[][2]={
{ 0x4200e000, 0000000000 },
{ 0x4000e000, 0000000000 },
{ 0x00000099, 0x00000008 },

View File

@ -315,26 +315,26 @@ xf86TokenToString(SymTabPtr table, int token)
RHDPtr FindPciDevice()
{
const PciChipset_t *dev;
u32 bus, last_bus;
u32_t bus, last_bus;
if( (last_bus = PciApi(1))==-1)
return 0;
for(bus=0;bus<=last_bus;bus++)
{
u32 devfn;
u32_t devfn;
for(devfn=0;devfn<256;devfn++)
{
u32 id;
u32_t id;
id = PciRead32(bus,devfn, 0);
if( (CARD16)id != VENDOR_ATI)
if( (u16_t)id != VENDOR_ATI)
continue;
if( (dev=PciDevMatch(id>>16,RHDPCIchipsets))!=NULL)
{
CARD32 reg2C;
u32_t reg2C;
int i;
rhd.PciDeviceID = (id>>16);
@ -352,7 +352,7 @@ RHDPtr FindPciDevice()
for (i = 0; i < 6; i++)
{
CARD32 base;
u32_t base;
Bool validSize;
base = PciRead32(bus,devfn, PCI_MAP_REG_START + (i << 2));
@ -360,12 +360,12 @@ RHDPtr FindPciDevice()
{
if (base & PCI_MAP_IO)
{
rhd.ioBase[i] = (CARD32)PCIGETIO(base);
rhd.ioBase[i] = (u32_t)PCIGETIO(base);
rhd.memtype[i] = base & PCI_MAP_IO_ATTR_MASK;
}
else
{
rhd.memBase[i] = (CARD32)PCIGETMEMORY(base);
rhd.memBase[i] = (u32_t)PCIGETMEMORY(base);
rhd.memtype[i] = base & PCI_MAP_MEMORY_ATTR_MASK;
}
}
@ -380,7 +380,7 @@ RHDPtr FindPciDevice()
return NULL;
}
const PciChipset_t *PciDevMatch(CARD16 dev,const PciChipset_t *list)
const PciChipset_t *PciDevMatch(u16_t dev,const PciChipset_t *list)
{
while(list->device)
{
@ -392,13 +392,13 @@ const PciChipset_t *PciDevMatch(CARD16 dev,const PciChipset_t *list)
}
CARD32 pciGetBaseSize(int bus, int devfn, int index, Bool destructive, Bool *min)
u32_t pciGetBaseSize(int bus, int devfn, int index, Bool destructive, Bool *min)
{
int offset;
CARD32 addr1;
CARD32 addr2;
CARD32 mask1;
CARD32 mask2;
u32_t addr1;
u32_t addr2;
u32_t mask1;
u32_t mask2;
int bits = 0;
/*

View File

@ -3,8 +3,8 @@
#pragma pack(push, 1)
typedef struct
{
CARD16 device;
CARD16 ChipSet;
u16_t device;
u16_t ChipSet;
}PciChipset_t;
#pragma pack(pop)
@ -75,5 +75,5 @@ pciTag(int busnum, int devnum, int funcnum)
return(PCI_MAKE_TAG(busnum,devnum,funcnum));
}
const PciChipset_t *PciDevMatch(CARD16 dev,const PciChipset_t *list);
CARD32 pciGetBaseSize(int bus, int devfn, int index, Bool destructive, Bool *min);
const PciChipset_t *PciDevMatch(u16_t dev,const PciChipset_t *list);
u32_t pciGetBaseSize(int bus, int devfn, int index, Bool destructive, Bool *min);

View File

@ -0,0 +1,98 @@
int CreatePixmap(pixmap_t *io)
{
local_pixmap_t *pixmap;
unsigned pitch;
size_t size;
void *local;
if( (io->width == 0) || (io->width > 2048)||
(io->height == 0)|| (io->height > 2048))
{
dbgprintf("Invalid pixmap size w:%d h:%d\n", io->width,io->height);
return ERR_PARAM;
};
pitch = ((io->width+15)&~15)*4;
size = pitch*io->height;
dbgprintf("pitch = %d\n", pitch);
local = rhd_mem_alloc(&rhd,RHD_MEM_FB,size) ;
if ( !local)
{
dbgprintf("Not enough memory for pixmap\n");
return ERR_PARAM;
};
pixmap = malloc(sizeof(local_pixmap_t));
if(!pixmap)
{
rhd_mem_free(&rhd, RHD_MEM_FB,local);
return ERR_PARAM;
}
else
{
void *mapped;
size = (size+4095) & ~ 4095;
if (mapped = UserAlloc(size))
{
CommitPages(mapped, ((u32_t)local+rhd.PhisBase)|7|(1<<9), size);
io->mapped = mapped;
io->pitch = pitch;
io->handle = (u32_t)pixmap;
pixmap->width = io->width;
pixmap->height = io->height;
pixmap->format = PICT_a8r8g8b8;
pixmap->flags = io->flags;
pixmap->pitch = pitch;
pixmap->mapped = mapped;
pixmap->pitch_offset = ((pitch/64)<<22)| (((u32_t)local+rhd.FbIntAddress)>>10);
pixmap->local = local;
dbgprintf("pixmap.pitch_offset: %x\n", pixmap->pitch_offset);
dbgprintf("width: %d height: %d\n",pixmap->width,pixmap->height );
dbgprintf("map at %x\n", pixmap->mapped);
return ERR_OK;
};
rhd_mem_free(&rhd, RHD_MEM_FB,local);
free(pixmap);
};
return ERR_PARAM;
};
int DestroyPixmap( pixmap_t *io )
{
local_pixmap_t *pixmap;
size_t size;
dbgprintf("Destroy pixmap %x\n", io->handle);
if(io->handle == -1)
return ERR_PARAM;
else
pixmap = (local_pixmap_t*)io->handle;
size = (pixmap->pitch*pixmap->height+4095) & ~ 4095;
UnmapPages(pixmap->mapped, size);
UserFree(pixmap->mapped);
rhd_mem_free(&rhd,RHD_MEM_FB,pixmap->local);
free(pixmap);
io->format = 0;
io->pitch = 0;
io->mapped = NULL;
io->handle = 0;
return ERR_OK;
};

View File

@ -119,7 +119,7 @@ void RADEONOUTPLL(int addr, u32_t data)
static Bool
R5xxFIFOWaitLocal(CARD32 required) //R100-R500
R5xxFIFOWaitLocal(u32_t required) //R100-R500
{
int i;
@ -183,7 +183,7 @@ R5xx2DIdleLocal() //R100-R500
static void
R5xx2DReset()
{
CARD32 save, tmp;
u32_t save, tmp;
u32_t clock_cntl_index;
u32_t mclk_cntl;
@ -285,7 +285,7 @@ R5xx2DSetup()
R5xx2DIdleLocal();
}
void R5xxFIFOWait(CARD32 required)
void R5xxFIFOWait(u32_t required)
{
if (!R5xxFIFOWaitLocal(required)) {
R5xx2DReset();
@ -303,7 +303,7 @@ void R5xx2DIdle()
static void load_microcode()
{
u32 ifl;
u32_t ifl;
int i;
ifl = safe_cli();
@ -350,7 +350,7 @@ static void load_microcode()
void R5xx2DInit()
{
u32 base;
u32_t base;
#ifdef R300_TEST
rhd.displayWidth = 1024;

View File

@ -1,5 +1,6 @@
IMP
_KernelAlloc core.KernelAlloc,
_KernelFree core.KernelFree,
_UserAlloc core.UserAlloc,
_UserFree core.UserFree,
_CommitPages core.CommitPages,
@ -21,10 +22,5 @@ IMP
FIL ati2d.obj,
helper.obj,
dbg.obj,
malloc.obj,
memset.obj,
string.obj,
vsprintf.obj,
icompute.obj

View File

@ -1,128 +0,0 @@
#include "common.h"
char * strcat(char *s, const char *append)
{
int d0, d1, d2, d3;
__asm__ __volatile__(
"repne\n\t"
"scasb\n\t"
"decl %1\n"
"1:\tlodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b"
: "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3)
: "0" (append),"1"(s),"2"(0),"3" (0xffffffff):"memory");
return s;
}
int
memcmp(const void *s1, const void *s2, size_t n)
{
if (n != 0)
{
const unsigned char *p1 = s1, *p2 = s2;
do {
if (*p1++ != *p2++)
return (*--p1 - *--p2);
} while (--n != 0);
}
return 0;
}
void * memcpy(void * _dest, const void *_src, size_t _n)
{
int d0, d1, d2;
__asm__ __volatile__(
"jcxz 1f\n\t"
"rep ; movsl\n\t"
"1:\t"
"testb $2,%b4\n\t"
"je 1f\n\t"
"movsw\n"
"1:\ttestb $1,%b4\n\t"
"je 2f\n\t"
"movsb\n"
"2:"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
:"0" (_n/4), "q" (_n),"1" ((long)_dest),"2" ((long)_src)
: "memory");
return (_dest);
}
char * strcpy(char *to, const char *from)
{
int d0, d1, d2;
__asm__ __volatile__(
"1:\tlodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b"
: "=&S" (d0), "=&D" (d1), "=&a" (d2)
:"0" (from),"1" (to) : "memory");
return to;
}
int strcmp(const char *s1, const char *s2)
{
int d0, d1;
register int __res;
__asm__ __volatile__(
"1:\tlodsb\n\t"
"scasb\n\t"
"jne 2f\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n\t"
"xorl %%eax,%%eax\n\t"
"jmp 3f\n"
"2:\tsbbl %%eax,%%eax\n\t"
"orb $1,%%al\n"
"3:"
:"=a" (__res), "=&S" (d0), "=&D" (d1)
:"1" (s1),"2" (s2));
return __res;
}
size_t strlen(const char *str)
{
int d0;
register int __res;
__asm__ __volatile__(
"repne\n\t"
"scasb\n\t"
"notl %0\n\t"
"decl %0"
:"=c" (__res), "=&D" (d0) :"1" (str),"a" (0), "0" (0xffffffff));
return __res;
}
char * strdup(const char *_s)
{
char *rv;
if (_s == 0)
return 0;
rv = (char *)kmalloc(strlen(_s) + 1);
if (rv == 0)
return 0;
strcpy(rv, _s);
return rv;
}
char * strchr(const char *s, int c)
{
int d0;
register char * __res;
__asm__ __volatile__(
"movb %%al,%%ah\n"
"1:\tlodsb\n\t"
"cmpb %%ah,%%al\n\t"
"je 2f\n\t"
"testb %%al,%%al\n\t"
"jne 1b\n\t"
"movl $1,%1\n"
"2:\tmovl %1,%0\n\t"
"decl %0"
:"=a" (__res), "=&S" (d0) : "1" (s),"0" (c));
return __res;
}

View File

@ -0,0 +1,205 @@
#define OS_BASE 0x80000000
typedef struct
{
u32_t handle;
u32_t io_code;
void *input;
int inp_size;
void *output;
int out_size;
}ioctl_t;
typedef int (__stdcall *srv_proc_t)(ioctl_t *);
#define ERR_OK 0
#define ERR_PARAM -1
u32_t __stdcall drvEntry(int)__asm__("_drvEntry");
///////////////////////////////////////////////////////////////////////////////
#define STDCALL __attribute__ ((stdcall)) __attribute__ ((dllimport))
#define IMPORT __attribute__ ((dllimport))
///////////////////////////////////////////////////////////////////////////////
#define SysMsgBoardStr __SysMsgBoardStr
#define PciApi __PciApi
//#define RegService __RegService
#define CreateObject __CreateObject
#define DestroyObject __DestroyObject
///////////////////////////////////////////////////////////////////////////////
#define PG_SW 0x003
#define PG_NOCACHE 0x018
void* STDCALL AllocKernelSpace(size_t size)__asm__("AllocKernelSpace");
void* STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc");
void* STDCALL KernelFree(void *mem)__asm__("KernelFree");
void* STDCALL UserAlloc(size_t size)__asm__("UserAlloc");
int STDCALL UserFree(void *mem)__asm__("UserFree");
void* STDCALL CreateRingBuffer(size_t size, u32_t map)__asm__("CreateRingBuffer");
u32_t STDCALL RegService(char *name, srv_proc_t proc)__asm__("RegService");
//void *CreateObject(u32 pid, size_t size);
//void *DestroyObject(void *obj);
u32_t STDCALL MapIoMem(void* base,size_t size,u32_t flags)__asm__("MapIoMem");
///////////////////////////////////////////////////////////////////////////////
static u32_t PciApi(int cmd);
u8_t STDCALL PciRead8 (u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead8");
u16_t STDCALL PciRead16(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead16");
u32_t STDCALL PciRead32(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead32");
u32_t STDCALL PciWrite8 (u32_t bus, u32_t devfn, u32_t reg,u8_t val) __asm__("PciWrite8");
u32_t STDCALL PciWrite16(u32_t bus, u32_t devfn, u32_t reg,u16_t val)__asm__("PciWrite16");
u32_t STDCALL PciWrite32(u32_t bus, u32_t devfn, u32_t reg,u32_t val)__asm__("PciWrite32");
///////////////////////////////////////////////////////////////////////////////
int dbg_open(char *path);
int dbgprintf(const char* format, ...);
///////////////////////////////////////////////////////////////////////////////
extern inline u32_t GetPgAddr(void *mem)
{
u32_t retval;
__asm__ __volatile__ (
"call *__imp__GetPgAddr \n\t"
:"=eax" (retval)
:"a" (mem) );
return retval;
};
extern inline void CommitPages(void *mem, u32_t page, u32_t size)
{
size = (size+4095) & ~4095;
__asm__ __volatile__ (
"call *__imp__CommitPages"
::"a" (page), "b"(mem),"c"(size>>12)
:"edx" );
__asm__ __volatile__ ("":::"eax","ebx","ecx");
};
extern inline void UnmapPages(void *mem, size_t size)
{
size = (size+4095) & ~4095;
__asm__ __volatile__ (
"call *__imp__UnmapPages"
::"a" (mem), "c"(size>>12)
:"edx");
__asm__ __volatile__ ("":::"eax","ecx");
};
extern inline void usleep(u32_t delay)
{
if( !delay )
delay++;
delay*=2000;
__asm__ __volatile__ (
"1:\n\t"
"xorl %%eax, %%eax \n\t"
"cpuid \n\t"
"decl %%edi \n\t"
"jnz 1b"
:
:"D"(delay)
:"eax","ebx","ecx","edx");
};
extern inline u32_t __PciApi(int cmd)
{
u32_t retval;
__asm__ __volatile__ (
"call *__imp__PciApi"
:"=a" (retval)
:"a" (cmd)
:"memory");
return retval;
};
extern inline void* __CreateObject(u32_t pid, size_t size)
{
void *retval;
__asm__ __volatile__ (
"call *__imp__CreateObject \n\t"
:"=a" (retval)
:"a" (size),"b"(pid)
:"esi","edi", "memory");
return retval;
}
extern inline void *__DestroyObject(void *obj)
{
__asm__ __volatile__ (
"call *__imp__DestroyObject"
:
:"a" (obj)
:"ebx","edx","esi","edi", "memory");
}
/*
u32 __RegService(char *name, srv_proc_t proc)
{
u32 retval;
asm __volatile__
(
"pushl %%eax \n\t"
"pushl %%ebx \n\t"
"call *__imp__RegService \n\t"
:"=eax" (retval)
:"a" (proc), "b" (name)
:"memory"
);
return retval;
};
*/
extern inline u32_t safe_cli(void)
{
u32_t ifl;
__asm__ __volatile__ (
"pushf\n\t"
"popl %0\n\t"
"cli\n"
: "=r" (ifl));
return ifl;
}
extern inline void safe_sti(u32_t ifl)
{
__asm__ __volatile__ (
"pushl %0\n\t"
"popf\n"
: : "r" (ifl)
);
}
extern inline void __clear (void * dst, unsigned len)
{
u32_t tmp;
__asm__ __volatile__ (
// "xorl %%eax, %%eax \n\t"
"cld \n\t"
"rep stosb \n"
:"=c"(tmp),"=D"(tmp)
:"a"(0),"c"(len),"D"(dst));
__asm__ __volatile__ ("":::"ecx","edi");
};

View File

@ -0,0 +1,19 @@
#define NULL (void*)0
typedef unsigned char u8_t;
typedef unsigned short int u16_t;
typedef unsigned int u32_t;
typedef unsigned long long u64_t;
typedef unsigned int size_t;
typedef unsigned int count_t;
typedef unsigned int eflags_t;
typedef int bool;
#define TRUE (bool)1
#define FALSE (bool)0

View File

@ -1,203 +0,0 @@
/* $XFree86: xc/include/Xmd.h,v 3.18tsi Exp $ */
/***********************************************************
Copyright 1987, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
#ifndef XMD_H
#define XMD_H 1
/* $Xorg: Xmd.h,v 1.4 2001/02/09 02:03:22 xorgcvs Exp $ */
/*
* Xmd.h: MACHINE DEPENDENT DECLARATIONS.
*/
/*
* Special per-machine configuration flags.
*/
#ifdef CRAY
#define WORD64 /* 64-bit architecture */
#endif
#if defined (_LP64) || \
defined(__alpha) || defined(__alpha__) || \
defined(__ia64__) || defined(ia64) || \
defined(__sparc64__) || \
defined(__s390x__) || \
(defined(__hppa__) && defined(__LP64__)) || \
defined(__amd64__) || defined(amd64) || \
defined(__powerpc64__) || \
(defined(sgi) && (_MIPS_SZLONG == 64))
#define LONG64 /* 32/64-bit architecture */
#endif
/*
* Stuff to handle large architecture machines; the constants were generated
* on a 32-bit machine and must coorespond to the protocol.
*/
#ifdef WORD64
#define MUSTCOPY
#endif /* WORD64 */
/*
* Definition of macro used to set constants for size of network structures;
* machines with preprocessors that can't handle all of the sz_ symbols
* can define this macro to be sizeof(x) if and only if their compiler doesn't
* pad out structures (esp. the xTextElt structure which contains only two
* one-byte fields). Network structures should always define sz_symbols.
*
* The sz_ prefix is used instead of something more descriptive so that the
* symbols are no more than 32 characters long (which causes problems for some
* compilers and preprocessors).
*
* The extra indirection in the __STDC__ case is to get macro arguments to
* expand correctly before the concatenation, rather than afterward.
*/
#if ((defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)) && !defined(UNIXCPP)) || defined(ANSICPP)
#define _SIZEOF(x) sz_##x
#define SIZEOF(x) _SIZEOF(x)
#else
#define SIZEOF(x) sz_/**/x
#endif /* if ANSI C compiler else not */
/*
* Bitfield suffixes for the protocol structure elements, if you
* need them. Note that bitfields are not guarranteed to be signed
* (or even unsigned) according to ANSI C.
*/
#ifdef WORD64
typedef long INT64;
typedef unsigned long CARD64;
#define B32 :32
#define B16 :16
#ifdef UNSIGNEDBITFIELDS
typedef unsigned int INT32;
typedef unsigned int INT16;
#else
#ifdef __STDC__
typedef signed int INT32;
typedef signed int INT16;
#else
typedef int INT32;
typedef int INT16;
#endif
#endif
#else
#define B32
#define B16
#ifdef LONG64
typedef long INT64;
typedef int INT32;
#else
typedef long INT32;
#endif
typedef short INT16;
#endif
#if defined(__STDC__) || defined(sgi) || defined(AIXV3)
typedef signed char INT8;
#else
typedef char INT8;
#endif
#ifdef LONG64
typedef unsigned long CARD64;
typedef unsigned int CARD32;
#else
typedef unsigned long CARD32;
#endif
typedef unsigned short CARD16;
typedef unsigned char CARD8;
typedef CARD32 BITS32;
typedef CARD16 BITS16;
#ifndef I_NEED_OS2_H
typedef CARD8 BYTE;
typedef CARD8 BOOL;
#else
#define BYTE CARD8
#define BOOL CARD8
#endif
/*
* definitions for sign-extending bitfields on 64-bit architectures
*/
#if defined(WORD64) && defined(UNSIGNEDBITFIELDS)
#define cvtINT8toInt(val) (((val) & 0x00000080) ? ((val) | 0xffffffffffffff00) : (val))
#define cvtINT16toInt(val) (((val) & 0x00008000) ? ((val) | 0xffffffffffff0000) : (val))
#define cvtINT32toInt(val) (((val) & 0x80000000) ? ((val) | 0xffffffff00000000) : (val))
#define cvtINT8toShort(val) cvtINT8toInt(val)
#define cvtINT16toShort(val) cvtINT16toInt(val)
#define cvtINT32toShort(val) cvtINT32toInt(val)
#define cvtINT8toLong(val) cvtINT8toInt(val)
#define cvtINT16toLong(val) cvtINT16toInt(val)
#define cvtINT32toLong(val) cvtINT32toInt(val)
#else
#define cvtINT8toInt(val) (val)
#define cvtINT16toInt(val) (val)
#define cvtINT32toInt(val) (val)
#define cvtINT8toShort(val) (val)
#define cvtINT16toShort(val) (val)
#define cvtINT32toShort(val) (val)
#define cvtINT8toLong(val) (val)
#define cvtINT16toLong(val) (val)
#define cvtINT32toLong(val) (val)
#endif /* WORD64 and UNSIGNEDBITFIELDS */
#ifdef MUSTCOPY
/*
* This macro must not cast or else pointers will get aligned and be wrong
*/
#define NEXTPTR(p,t) (((char *) p) + SIZEOF(t))
#else /* else not MUSTCOPY, this is used for 32-bit machines */
/*
* this version should leave result of type (t *), but that should only be
* used when not in MUSTCOPY
*/
#define NEXTPTR(p,t) (((t *)(p)) + 1)
#endif /* MUSTCOPY - used machines whose C structs don't line up with proto */
#endif /* XMD_H */