unlock pixmaps

git-svn-id: svn://kolibrios.org@818 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-07-04 18:52:25 +00:00
parent 947f48e392
commit e5ba650fda
12 changed files with 4576 additions and 7 deletions

View File

@ -7,7 +7,7 @@
#define PIXMAP 6
#define PIXBLIT 7
#define PIXLOCK 8
#define PIXUNLOCK 9
typedef unsigned int color_t;
@ -168,3 +168,4 @@ do { \
INREG( RADEON_CP_RB_RPTR ); \
} while (0)

View File

@ -305,14 +305,14 @@ int LockPixmap(userpixmap_t *io)
else
pixmap = io->pixmap;
if(pixmap->flags & 1 == 1 )
if( (pixmap->flags & 1) == PX_LOCK )
return ERR_PARAM;
size = pixmap->pitch*pixmap->width;
size = (pixmap->pitch*pixmap->width+4095) & ~ 4095;
if (usermap = UserAlloc(size))
{
CommitPages(usermap, ((u32_t)pixmap->raw+rhd.PhisBase)|7|(1<<9), size);
pixmap->flags |= 1;
pixmap->flags |= PX_LOCK;
pixmap->usermap = usermap;
io->usermap = usermap;
io->pitch = pixmap->pitch;
@ -324,6 +324,33 @@ int LockPixmap(userpixmap_t *io)
return ERR_PARAM;
};
int UnlockPixmap(userpixmap_t *io)
{
pixmap_t *pixmap;
size_t size;
dbgprintf("Unlock pixmap %x\n", io->pixmap);
if(io->pixmap == (pixmap_t*)-1)
return ERR_PARAM;
else
pixmap = io->pixmap;
if( (pixmap->flags & 1) != PX_LOCK )
return ERR_PARAM;
size = (pixmap->pitch*pixmap->width+4095) & ~ 4095;
UnmapPages(pixmap->usermap, size);
UserFree(pixmap->usermap);
pixmap->usermap = NULL;
pixmap->flags &= ~PX_LOCK;
io->usermap = NULL;
io->pitch = 0;
return ERR_OK;
};
int PixBlit(pixblit_t *blit)
{

View File

@ -177,6 +177,11 @@ int _stdcall srv_2d(ioctl_t *io)
return LockPixmap((userpixmap_t*)inp);
break;
case PIXUNLOCK:
if(io->inp_size==6)
return UnlockPixmap((userpixmap_t*)inp);
break;
default:
return ERR_PARAM;
};

View File

@ -189,6 +189,7 @@ typedef struct
void* usermap;
}pixmap_t;
#define PX_LOCK 1
typedef struct {
int token; /* id of the token */

View File

@ -57,6 +57,8 @@ u32_t __stdcall drvEntry(int)__asm__("_drvEntry");
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 *);
@ -89,6 +91,12 @@ static inline void CommitPages(void *mem, u32_t page, u32_t size)
:
:"a" (page), "b"(mem),"c"(size>>12)
:"edx"
);
asm volatile (
""
:
:
:"eax","ebx","ecx"
);
@ -100,8 +108,15 @@ static inline void UnmapPages(void *mem, size_t size)
"call *__imp__UnmapPages"
:
:"a" (mem), "c"(size>>12)
:"eax","ecx", "edx"
:"edx"
);
asm volatile (
""
:
:
:"eax","ecx"
);
}
///////////////////////////////////////////////////////////////////////////////
@ -204,3 +219,4 @@ int _stdcall srv_cursor(ioctl_t *io);
int _stdcall srv_2d(ioctl_t *io);

View File

@ -7,7 +7,7 @@ cursor_t *create_cursor(u32 pid, void *src, u32 flags)
cursor_t *cursor = (cursor_t*)CreateObject(pid, 32);
if(cursor==0)
if(cursor==NULL)
return 0;
dbgprintf("create object at %x\n", cursor);
@ -15,7 +15,7 @@ cursor_t *create_cursor(u32 pid, void *src, u32 flags)
cursor->destroy = __destroy_cursor;
img = rhd_mem_alloc(&rhd,RHD_MEM_FB,64*64*4);
if(img==0)
if(img==NULL)
goto cleanup;
dbgprintf("alloc video memory at %x size %x\n",img,64*64*4);

View File

@ -0,0 +1,55 @@
CC = gcc
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 \
microcode.h
SRC_DEP:= init.c \
pci.c \
ati_mem.c \
r500.inc \
accel_2d.inc \
accel_3d.inc
ATI_SRC:= ati2d.c \
malloc.c \
helper.c \
string.c \
dbg.c \
memset.asm
ATI_OBJ:= ati2d.obj
ATI_OBJ = $(patsubst %.s, %.obj, $(patsubst %.asm, %.obj,\
$(patsubst %.c, %.obj, $(ATI_SRC))))
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
kpack.exe ati2d.dll ati2d.drv
ati2d.obj : ati2d.c $(SRC_DEP) $(HFILES)
$(CC) $(CFLAGS) -o ati2d.obj ati2d.c
curhelp.obj : curhelp.asm
$(FASM) curhelp.asm
%.obj : %.c $(HFILES)
$(CC) $(CFLAGS) -o $@ $<
%.obj: %.asm
as -o $@ $<

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
/* 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

@ -0,0 +1,288 @@
/*
* Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
* VA Linux Systems Inc., Fremont, California.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) 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
* NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR
* THEIR SUPPLIERS 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.
*/
/* WARNING: the above is not a standard MIT license. */
/*
* Authors:
* Kevin E. Martin <martin@xfree86.org>
* Rickard E. Faith <faith@valinux.com>
* Alan Hourihane <alanh@fairlite.demon.co.uk>
*/
#ifndef _R5XX_2DREGS_H
# define _R5XX_2DREGS_H
#define R5XX_DATATYPE_VQ 0
#define R5XX_DATATYPE_CI4 1
#define R5XX_DATATYPE_CI8 2
#define R5XX_DATATYPE_ARGB1555 3
#define R5XX_DATATYPE_RGB565 4
#define R5XX_DATATYPE_RGB888 5
#define R5XX_DATATYPE_ARGB8888 6
#define R5XX_DATATYPE_RGB332 7
#define R5XX_DATATYPE_Y8 8
#define R5XX_DATATYPE_RGB8 9
#define R5XX_DATATYPE_CI16 10
#define R5XX_DATATYPE_VYUY_422 11
#define R5XX_DATATYPE_YVYU_422 12
#define R5XX_DATATYPE_AYUV_444 14
#define R5XX_DATATYPE_ARGB4444 15
#define R5XX_RBBM_SOFT_RESET 0x00f0
# define R5XX_SOFT_RESET_CP (1 << 0)
# define R5XX_SOFT_RESET_HI (1 << 1)
# define R5XX_SOFT_RESET_SE (1 << 2)
# define R5XX_SOFT_RESET_RE (1 << 3)
# define R5XX_SOFT_RESET_PP (1 << 4)
# define R5XX_SOFT_RESET_E2 (1 << 5)
# define R5XX_SOFT_RESET_RB (1 << 6)
# define R5XX_SOFT_RESET_HDP (1 << 7)
#define R5XX_HOST_PATH_CNTL 0x0130
# define R5XX_HDP_SOFT_RESET (1 << 26)
# define R5XX_HDP_APER_CNTL (1 << 23)
#define R5XX_SURFACE_CNTL 0x0b00
# define R5XX_SURF_TRANSLATION_DIS (1 << 8)
# define R5XX_NONSURF_AP0_SWP_16BPP (1 << 20)
# define R5XX_NONSURF_AP0_SWP_32BPP (1 << 21)
# define R5XX_NONSURF_AP1_SWP_16BPP (1 << 22)
# define R5XX_NONSURF_AP1_SWP_32BPP (1 << 23)
#define R5XX_SURFACE0_INFO 0x0b0c
# define R5XX_SURF_TILE_COLOR_MACRO (0 << 16)
# define R5XX_SURF_TILE_COLOR_BOTH (1 << 16)
# define R5XX_SURF_TILE_DEPTH_32BPP (2 << 16)
# define R5XX_SURF_TILE_DEPTH_16BPP (3 << 16)
# define R5XX_SURF_AP0_SWP_16BPP (1 << 20)
# define R5XX_SURF_AP0_SWP_32BPP (1 << 21)
# define R5XX_SURF_AP1_SWP_16BPP (1 << 22)
# define R5XX_SURF_AP1_SWP_32BPP (1 << 23)
#define R5XX_SURFACE0_LOWER_BOUND 0x0b04
#define R5XX_SURFACE0_UPPER_BOUND 0x0b08
#define R5XX_RBBM_STATUS 0x0e40
# define R5XX_RBBM_FIFOCNT_MASK 0x007f
# define R5XX_RBBM_ACTIVE (1 << 31)
#define R5XX_SRC_PITCH_OFFSET 0x1428
#define R5XX_DST_PITCH_OFFSET 0x142c
#define R5XX_SRC_Y_X 0x1434
#define R5XX_DST_Y_X 0x1438
#define R5XX_DST_HEIGHT_WIDTH 0x143c
#define R5XX_DP_GUI_MASTER_CNTL 0x146c
# define R5XX_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0)
# define R5XX_GMC_DST_PITCH_OFFSET_CNTL (1 << 1)
# define R5XX_GMC_SRC_CLIPPING (1 << 2)
# define R5XX_GMC_DST_CLIPPING (1 << 3)
# define R5XX_GMC_BRUSH_DATATYPE_MASK (0x0f << 4)
# define R5XX_GMC_BRUSH_8X8_MONO_FG_BG (0 << 4)
# define R5XX_GMC_BRUSH_8X8_MONO_FG_LA (1 << 4)
# define R5XX_GMC_BRUSH_1X8_MONO_FG_BG (4 << 4)
# define R5XX_GMC_BRUSH_1X8_MONO_FG_LA (5 << 4)
# define R5XX_GMC_BRUSH_32x1_MONO_FG_BG (6 << 4)
# define R5XX_GMC_BRUSH_32x1_MONO_FG_LA (7 << 4)
# define R5XX_GMC_BRUSH_32x32_MONO_FG_BG (8 << 4)
# define R5XX_GMC_BRUSH_32x32_MONO_FG_LA (9 << 4)
# define R5XX_GMC_BRUSH_8x8_COLOR (10 << 4)
# define R5XX_GMC_BRUSH_1X8_COLOR (12 << 4)
# define R5XX_GMC_BRUSH_SOLID_COLOR (13 << 4)
# define R5XX_GMC_BRUSH_NONE (15 << 4)
# define R5XX_GMC_DST_8BPP_CI (2 << 8)
# define R5XX_GMC_DST_15BPP (3 << 8)
# define R5XX_GMC_DST_16BPP (4 << 8)
# define R5XX_GMC_DST_24BPP (5 << 8)
# define R5XX_GMC_DST_32BPP (6 << 8)
# define R5XX_GMC_DST_8BPP_RGB (7 << 8)
# define R5XX_GMC_DST_Y8 (8 << 8)
# define R5XX_GMC_DST_RGB8 (9 << 8)
# define R5XX_GMC_DST_VYUY (11 << 8)
# define R5XX_GMC_DST_YVYU (12 << 8)
# define R5XX_GMC_DST_AYUV444 (14 << 8)
# define R5XX_GMC_DST_ARGB4444 (15 << 8)
# define R5XX_GMC_DST_DATATYPE_MASK (0x0f << 8)
# define R5XX_GMC_DST_DATATYPE_SHIFT 8
# define R5XX_GMC_SRC_DATATYPE_MASK (3 << 12)
# define R5XX_GMC_SRC_DATATYPE_MONO_FG_BG (0 << 12)
# define R5XX_GMC_SRC_DATATYPE_MONO_FG_LA (1 << 12)
# define R5XX_GMC_SRC_DATATYPE_COLOR (3 << 12)
# define R5XX_GMC_BYTE_PIX_ORDER (1 << 14)
# define R5XX_GMC_BYTE_MSB_TO_LSB (0 << 14)
# define R5XX_GMC_BYTE_LSB_TO_MSB (1 << 14)
# define R5XX_GMC_CONVERSION_TEMP (1 << 15)
# define R5XX_GMC_CONVERSION_TEMP_6500 (0 << 15)
# define R5XX_GMC_CONVERSION_TEMP_9300 (1 << 15)
# define R5XX_GMC_ROP3_MASK (0xff << 16)
# define R5XX_DP_SRC_SOURCE_MASK (7 << 24)
# define R5XX_DP_SRC_SOURCE_MEMORY (2 << 24)
# define R5XX_DP_SRC_SOURCE_HOST_DATA (3 << 24)
# define R5XX_GMC_3D_FCN_EN (1 << 27)
# define R5XX_GMC_CLR_CMP_CNTL_DIS (1 << 28)
# define R5XX_GMC_AUX_CLIP_DIS (1 << 29)
# define R5XX_GMC_WR_MSK_DIS (1 << 30)
# define R5XX_GMC_LD_BRUSH_Y_X (1 << 31)
# define R5XX_ROP3_ZERO 0x00000000
# define R5XX_ROP3_DSa 0x00880000
# define R5XX_ROP3_SDna 0x00440000
# define R5XX_ROP3_S 0x00cc0000
# define R5XX_ROP3_DSna 0x00220000
# define R5XX_ROP3_D 0x00aa0000
# define R5XX_ROP3_DSx 0x00660000
# define R5XX_ROP3_DSo 0x00ee0000
# define R5XX_ROP3_DSon 0x00110000
# define R5XX_ROP3_DSxn 0x00990000
# define R5XX_ROP3_Dn 0x00550000
# define R5XX_ROP3_SDno 0x00dd0000
# define R5XX_ROP3_Sn 0x00330000
# define R5XX_ROP3_DSno 0x00bb0000
# define R5XX_ROP3_DSan 0x00770000
# define R5XX_ROP3_ONE 0x00ff0000
# define R5XX_ROP3_DPa 0x00a00000
# define R5XX_ROP3_PDna 0x00500000
# define R5XX_ROP3_P 0x00f00000
# define R5XX_ROP3_DPna 0x000a0000
# define R5XX_ROP3_D 0x00aa0000
# define R5XX_ROP3_DPx 0x005a0000
# define R5XX_ROP3_DPo 0x00fa0000
# define R5XX_ROP3_DPon 0x00050000
# define R5XX_ROP3_PDxn 0x00a50000
# define R5XX_ROP3_PDno 0x00f50000
# define R5XX_ROP3_Pn 0x000f0000
# define R5XX_ROP3_DPno 0x00af0000
# define R5XX_ROP3_DPan 0x005f0000
#define R5XX_BRUSH_Y_X 0x1474
#define R5XX_DP_BRUSH_BKGD_CLR 0x1478
#define R5XX_DP_BRUSH_FRGD_CLR 0x147c
#define R5XX_BRUSH_DATA0 0x1480
#define R5XX_BRUSH_DATA1 0x1484
#define R5XX_DST_WIDTH_HEIGHT 0x1598
#define R5XX_CLR_CMP_CNTL 0x15c0
# define R5XX_SRC_CMP_EQ_COLOR (4 << 0)
# define R5XX_SRC_CMP_NEQ_COLOR (5 << 0)
# define R5XX_CLR_CMP_SRC_SOURCE (1 << 24)
#define R5XX_CLR_CMP_CLR_SRC 0x15c4
#define R5XX_CLR_CMP_MASK 0x15cc
# define R5XX_CLR_CMP_MSK 0xffffffff
#define R5XX_DP_SRC_BKGD_CLR 0x15dc
#define R5XX_DP_SRC_FRGD_CLR 0x15d8
#define R5XX_DST_LINE_START 0x1600
#define R5XX_DST_LINE_END 0x1604
#define R5XX_DST_LINE_PATCOUNT 0x1608
# define R5XX_BRES_CNTL_SHIFT 8
#define R5XX_DP_CNTL 0x16c0
# define R5XX_DST_X_LEFT_TO_RIGHT (1 << 0)
# define R5XX_DST_Y_TOP_TO_BOTTOM (1 << 1)
# define R5XX_DP_DST_TILE_LINEAR (0 << 3)
# define R5XX_DP_DST_TILE_MACRO (1 << 3)
# define R5XX_DP_DST_TILE_MICRO (2 << 3)
# define R5XX_DP_DST_TILE_BOTH (3 << 3)
#define R5XX_DP_DATATYPE 0x16c4
# define R5XX_HOST_BIG_ENDIAN_EN (1 << 29)
#define R5XX_DP_WRITE_MASK 0x16cc
#define R5XX_DEFAULT_SC_BOTTOM_RIGHT 0x16e8
# define R5XX_DEFAULT_SC_RIGHT_MAX (0x1fff << 0)
# define R5XX_DEFAULT_SC_BOTTOM_MAX (0x1fff << 16)
#define R5XX_SC_TOP_LEFT 0x16ec
#define R5XX_SC_BOTTOM_RIGHT 0x16f0
# define R5XX_SC_SIGN_MASK_LO 0x8000
# define R5XX_SC_SIGN_MASK_HI 0x80000000
#define R5XX_RBBM_GUICNTL 0x172c
# define R5XX_HOST_DATA_SWAP_NONE (0 << 0)
# define R5XX_HOST_DATA_SWAP_16BIT (1 << 0)
# define R5XX_HOST_DATA_SWAP_32BIT (2 << 0)
# define R5XX_HOST_DATA_SWAP_HDW (3 << 0)
#define R5XX_HOST_DATA0 0x17c0
#define R5XX_HOST_DATA1 0x17c4
#define R5XX_HOST_DATA2 0x17c8
#define R5XX_HOST_DATA3 0x17cc
#define R5XX_HOST_DATA4 0x17d0
#define R5XX_HOST_DATA5 0x17d4
#define R5XX_HOST_DATA6 0x17d8
#define R5XX_HOST_DATA7 0x17dc
#define R5XX_HOST_DATA_LAST 0x17e0
#define R5XX_RB3D_CNTL 0x1c3c
# define R5XX_ALPHA_BLEND_ENABLE (1 << 0)
# define R5XX_PLANE_MASK_ENABLE (1 << 1)
# define R5XX_DITHER_ENABLE (1 << 2)
# define R5XX_ROUND_ENABLE (1 << 3)
# define R5XX_SCALE_DITHER_ENABLE (1 << 4)
# define R5XX_DITHER_INIT (1 << 5)
# define R5XX_ROP_ENABLE (1 << 6)
# define R5XX_STENCIL_ENABLE (1 << 7)
# define R5XX_Z_ENABLE (1 << 8)
# define R5XX_DEPTH_XZ_OFFEST_ENABLE (1 << 9)
# define R5XX_COLOR_FORMAT_ARGB1555 (3 << 10)
# define R5XX_COLOR_FORMAT_RGB565 (4 << 10)
# define R5XX_COLOR_FORMAT_ARGB8888 (6 << 10)
# define R5XX_COLOR_FORMAT_RGB332 (7 << 10)
# define R5XX_COLOR_FORMAT_Y8 (8 << 10)
# define R5XX_COLOR_FORMAT_RGB8 (9 << 10)
# define R5XX_COLOR_FORMAT_YUV422_VYUY (11 << 10)
# define R5XX_COLOR_FORMAT_YUV422_YVYU (12 << 10)
# define R5XX_COLOR_FORMAT_aYUV444 (14 << 10)
# define R5XX_COLOR_FORMAT_ARGB4444 (15 << 10)
# define R5XX_CLRCMP_FLIP_ENABLE (1 << 14)
#define R5XX_RB3D_DSTCACHE_CTLSTAT 0x325C
# define R5XX_RB3D_DC_FLUSH (3 << 0)
# define R5XX_RB3D_DC_FREE (3 << 2)
# define R5XX_RB3D_DC_FLUSH_ALL 0xf
# define R5XX_RB3D_DC_BUSY (1 << 31)
#define R5XX_RB3D_DSTCACHE_MODE 0x3258
# define R5XX_RB3D_DC_CACHE_ENABLE (0)
# define R5XX_RB3D_DC_2D_CACHE_DISABLE (1)
# define R5XX_RB3D_DC_3D_CACHE_DISABLE (2)
# define R5XX_RB3D_DC_CACHE_DISABLE (3)
# define R5XX_RB3D_DC_2D_CACHE_LINESIZE_128 (1 << 2)
# define R5XX_RB3D_DC_3D_CACHE_LINESIZE_128 (2 << 2)
# define R5XX_RB3D_DC_2D_CACHE_AUTOFLUSH (1 << 8)
# define R5XX_RB3D_DC_3D_CACHE_AUTOFLUSH (2 << 8)
# define R200_RB3D_DC_2D_CACHE_AUTOFREE (1 << 10)
# define R200_RB3D_DC_3D_CACHE_AUTOFREE (2 << 10)
# define R5XX_RB3D_DC_FORCE_RMW (1 << 16)
# define R5XX_RB3D_DC_DISABLE_RI_FILL (1 << 24)
# define R5XX_RB3D_DC_DISABLE_RI_READ (1 << 25)
#endif /* _R5XX_2DREGS_H */

View File

@ -0,0 +1,30 @@
IMP
_KernelAlloc core.KernelAlloc,
_UserAlloc core.UserAlloc,
_UserFree core.UserFree,
_CommitPages core.CommitPages,
_UnmapPages core.UnmapPages,
_CreateObject core.CreateObject,
_DestroyObject core.DestroyObject,
_MapIoMem core.MapIoMem,
_GetPgAddr core.GetPgAddr,
_CreateRingBuffer core.CreateRingBuffer,
_PciApi core.PciApi,
_PciRead32 core.PciRead32,
_PciWrite32 core.PciWrite32,
_RegService core.RegService,
_SysMsgBoardStr core.SysMsgBoardStr,
_SelectHwCursor core.SelectHwCursor,
_SetHwCursor core.SetHwCursor,
_HwCursorCreate core.HwCursorCreate,
_HwCursorRestore core.HwCursorRestore
FIL ati2d.obj,
helper.obj,
dbg.obj,
malloc.obj,
memset.obj,
string.obj,
vsprintf.obj,
icompute.obj

View File

@ -0,0 +1,128 @@
#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;
}