Improved error messages.
build fixes for AMD64. Made shm* functions in the libc_wrapper more standard conformant by setting errno correctly. Use xf86ExendedInitInt10() in VBEExtendedInit() to be able to pass flags.
This commit is contained in:
parent
7643199de1
commit
40b975e3ac
|
@ -1,7 +1,7 @@
|
|||
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c,v 1.30 2003/03/14 13:46:06 tsi Exp $ */
|
||||
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c,v 1.32 2004/02/05 18:24:59 eich Exp $ */
|
||||
/*
|
||||
* linux specific part of the int10 module
|
||||
* Copyright 1999 Egbert Eich
|
||||
* Copyright 1999, 2000, 2001, 2002, 2003, 2004 Egbert Eich
|
||||
*/
|
||||
#include "xf86.h"
|
||||
#include "xf86_OSproc.h"
|
||||
|
@ -172,6 +172,9 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
|
|||
if (errno == ENOSYS)
|
||||
xf86DrvMsg(screen, X_ERROR, "shmget error\n Please reconfigure"
|
||||
" your kernel to include System V IPC support\n");
|
||||
else
|
||||
xf86DrvMsg(screen, X_ERROR,
|
||||
"shmget(highmem) error: %s\n",strerror(errno));
|
||||
goto error1;
|
||||
}
|
||||
} else {
|
||||
|
@ -198,21 +201,34 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
|
|||
ErrorF("Mapping 640kB area\n");
|
||||
#endif
|
||||
if ((low_mem = shmget(counter++, V_RAM,
|
||||
IPC_CREAT | SHM_R | SHM_W)) == -1)
|
||||
IPC_CREAT | SHM_R | SHM_W)) == -1) {
|
||||
xf86DrvMsg(screen, X_ERROR,
|
||||
"shmget(lowmem) error: %s\n",strerror(errno));
|
||||
goto error2;
|
||||
}
|
||||
|
||||
((linuxInt10Priv*)pInt->private)->lowMem = low_mem;
|
||||
base = shmat(low_mem, 0, 0);
|
||||
if (base == SHMERRORPTR) goto error4;
|
||||
if (base == SHMERRORPTR) {
|
||||
xf86DrvMsg(screen, X_ERROR,
|
||||
"shmat(low_mem) error: %s\n",strerror(errno));
|
||||
goto error3;
|
||||
}
|
||||
((linuxInt10Priv *)pInt->private)->base = base;
|
||||
if (high_mem > -1) {
|
||||
base_high = shmat(high_mem, 0, 0);
|
||||
if (base_high == SHMERRORPTR) goto error4;
|
||||
if (base_high == SHMERRORPTR) {
|
||||
xf86DrvMsg(screen, X_ERROR,
|
||||
"shmat(high_mem) error: %s\n",strerror(errno));
|
||||
goto error3;
|
||||
}
|
||||
((linuxInt10Priv*)pInt->private)->base_high = base_high;
|
||||
} else
|
||||
((linuxInt10Priv*)pInt->private)->base_high = NULL;
|
||||
|
||||
MapCurrentInt10(pInt);
|
||||
if (!MapCurrentInt10(pInt))
|
||||
goto error3;
|
||||
|
||||
Int10Current = pInt;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -238,7 +254,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
|
|||
for (cs = V_BIOS; cs < SYS_BIOS; cs += V_BIOS_SIZE)
|
||||
if (xf86ReadBIOS(cs, 0, (pointer)cs, V_BIOS_SIZE) < V_BIOS_SIZE)
|
||||
xf86DrvMsg(screen, X_WARNING,
|
||||
"Unable to retrieve all of segment 0x%06X.\n", cs);
|
||||
"Unable to retrieve all of segment 0x%06lX.\n", cs);
|
||||
#ifdef DEBUG
|
||||
ErrorF("done\n");
|
||||
#endif
|
||||
|
@ -250,13 +266,13 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
|
|||
&& !(initPrimary(options))) {
|
||||
if (bios.bus == BUS_ISA && bios.location.legacy) {
|
||||
xf86DrvMsg(screen, X_CONFIG,
|
||||
"Overriding BIOS location: 0x%lx\n",
|
||||
"Overriding BIOS location: 0x%x\n",
|
||||
bios.location.legacy);
|
||||
cs = bios.location.legacy >> 4;
|
||||
bios_base = (unsigned char *)(cs << 4);
|
||||
if (!int10_check_bios(screen, cs, bios_base)) {
|
||||
xf86DrvMsg(screen, X_ERROR,
|
||||
"No V_BIOS at specified address 0x%x\n",cs << 4);
|
||||
"No V_BIOS at specified address 0x%lx\n",cs << 4);
|
||||
goto error3;
|
||||
}
|
||||
} else {
|
||||
|
@ -286,7 +302,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
|
|||
}
|
||||
}
|
||||
|
||||
xf86DrvMsg(screen, X_INFO, "Primary V_BIOS segment is: 0x%x\n", cs);
|
||||
xf86DrvMsg(screen, X_INFO, "Primary V_BIOS segment is: 0x%lx\n", cs);
|
||||
|
||||
pInt->BIOSseg = cs;
|
||||
set_return_trap(pInt);
|
||||
|
@ -345,7 +361,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
|
|||
bios_base = (unsigned char *)(cs << 4);
|
||||
if (!int10_check_bios(screen, cs, bios_base)) {
|
||||
xf86DrvMsg(screen,X_ERROR,"No V_BIOS found "
|
||||
"on override address 0x%x\n",bios_base);
|
||||
"on override address %p\n",bios_base);
|
||||
goto error3;
|
||||
}
|
||||
} else {
|
||||
|
@ -365,7 +381,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
|
|||
}
|
||||
}
|
||||
}
|
||||
xf86DrvMsg(screen,X_INFO,"Primary V_BIOS segment is: 0x%x\n",cs);
|
||||
xf86DrvMsg(screen,X_INFO,"Primary V_BIOS segment is: 0x%lx\n",cs);
|
||||
pInt->BIOSseg = cs;
|
||||
break;
|
||||
default:
|
||||
|
@ -386,8 +402,6 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
|
|||
xfree(options);
|
||||
return pInt;
|
||||
|
||||
error4:
|
||||
xf86DrvMsg(screen, X_ERROR, "shmat() call retruned errno %d\n", errno);
|
||||
error3:
|
||||
if (base_high)
|
||||
shmdt(base_high);
|
||||
|
@ -427,6 +441,8 @@ MapCurrentInt10(xf86Int10InfoPtr pInt)
|
|||
addr = shmat(((linuxInt10Priv*)pInt->private)->lowMem, (char*)1, SHM_RND);
|
||||
if (addr == SHMERRORPTR) {
|
||||
xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot shmat() low memory\n");
|
||||
xf86DrvMsg(pInt->scrnIndex, X_ERROR,
|
||||
"shmat(low_mem) error: %s\n",strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -436,6 +452,8 @@ MapCurrentInt10(xf86Int10InfoPtr pInt)
|
|||
if (addr == SHMERRORPTR) {
|
||||
xf86DrvMsg(pInt->scrnIndex, X_ERROR,
|
||||
"Cannot shmat() high memory\n");
|
||||
xf86DrvMsg(pInt->scrnIndex, X_ERROR,
|
||||
"shmget error: %s\n",strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c,v 1.96 2003/09/09 03:20:41 dawes Exp $ */
|
||||
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c,v 1.102 2003/11/19 03:52:58 dawes Exp $ */
|
||||
/*
|
||||
* Copyright 1997-2003 by The XFree86 Project, Inc.
|
||||
*
|
||||
|
@ -254,6 +254,18 @@ xf86strlen(const char* s)
|
|||
return (xf86size_t)strlen(s);
|
||||
}
|
||||
|
||||
xf86size_t
|
||||
xf86strlcat(char *dest, const char *src, xf86size_t size)
|
||||
{
|
||||
return(strlcat(dest, src, size));
|
||||
}
|
||||
|
||||
xf86size_t
|
||||
xf86strlcpy(char *dest, const char *src, xf86size_t size)
|
||||
{
|
||||
return strlcpy(dest, src, size);
|
||||
}
|
||||
|
||||
char*
|
||||
xf86strncat(char* dest, const char* src, xf86size_t n)
|
||||
{
|
||||
|
@ -484,7 +496,7 @@ xf86mmap(void *start, xf86size_t length, int prot,
|
|||
if (flags & XF86_MAP_FIXED) f |= MAP_FIXED;
|
||||
if (flags & XF86_MAP_SHARED) f |= MAP_SHARED;
|
||||
if (flags & XF86_MAP_PRIVATE) f |= MAP_PRIVATE;
|
||||
#ifdef __AMD64__
|
||||
#if defined(__amd64__) && defined(linux)
|
||||
if (flags & XF86_MAP_32BIT) f |= MAP_32BIT;
|
||||
#endif
|
||||
if (prot & XF86_PROT_EXEC) p |= PROT_EXEC;
|
||||
|
@ -658,7 +670,7 @@ static void _xf86checkhndl(XF86FILE_priv* f,const char *func)
|
|||
{
|
||||
if (!f || f->magic != XF86FILE_magic ||
|
||||
!f->filehnd || !f->fname) {
|
||||
FatalError("libc_wrapper error: passed invalid FILE handle to %s\n",
|
||||
FatalError("libc_wrapper error: passed invalid FILE handle to %s",
|
||||
func);
|
||||
exit(42);
|
||||
}
|
||||
|
@ -1091,7 +1103,7 @@ xf86setvbuf(XF86FILE* f, char *buf, int mode, xf86size_t size)
|
|||
vbufmode = _IOLBF;
|
||||
break;
|
||||
default:
|
||||
FatalError("libc_wrapper error: mode in setvbuf incorrect\n");
|
||||
FatalError("libc_wrapper error: mode in setvbuf incorrect");
|
||||
exit(42);
|
||||
}
|
||||
|
||||
|
@ -1301,7 +1313,7 @@ static void
|
|||
_xf86checkdirhndl(XF86DIR_priv* f,const char *func)
|
||||
{
|
||||
if (!f || f->magic != XF86DIR_magic || !f->dir || !f->dirent) {
|
||||
FatalError("libc_wrapper error: passed invalid DIR handle to %s\n",
|
||||
FatalError("libc_wrapper error: passed invalid DIR handle to %s",
|
||||
func);
|
||||
exit(42);
|
||||
}
|
||||
|
@ -1817,7 +1829,7 @@ xf86getpagesize()
|
|||
pagesize = PAGE_SIZE;
|
||||
#endif
|
||||
if (pagesize == -1)
|
||||
FatalError("xf86getpagesize: Cannot determine page size\n");
|
||||
FatalError("xf86getpagesize: Cannot determine page size");
|
||||
|
||||
return pagesize;
|
||||
}
|
||||
|
@ -1871,24 +1883,31 @@ xf86GetErrno ()
|
|||
int
|
||||
xf86shmget(xf86key_t key, int size, int xf86shmflg)
|
||||
{
|
||||
int shmflg = xf86shmflg & 0777;
|
||||
int shmflg;
|
||||
int ret;
|
||||
|
||||
/* This copies the permissions (SHM_R, SHM_W for u, g, o). */
|
||||
shmflg = xf86shmflg & 0777;
|
||||
|
||||
if (key == XF86IPC_PRIVATE) key = IPC_PRIVATE;
|
||||
|
||||
|
||||
if (xf86shmflg & XF86SHM_R) shmflg |= SHM_R;
|
||||
if (xf86shmflg & XF86SHM_W) shmflg |= SHM_W;
|
||||
if (xf86shmflg & XF86IPC_CREAT) shmflg |= IPC_CREAT;
|
||||
if (xf86shmflg & XF86IPC_EXCL) shmflg |= IPC_EXCL;
|
||||
if (xf86shmflg & XF86IPC_NOWAIT) shmflg |= IPC_NOWAIT;
|
||||
return shmget((key_t) key, size, shmflg);
|
||||
ret = shmget((key_t) key, size, shmflg);
|
||||
|
||||
if (ret == -1)
|
||||
xf86errno = xf86GetErrno();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *
|
||||
xf86shmat(int id, char *addr, int xf86shmflg)
|
||||
{
|
||||
int shmflg = 0;
|
||||
|
||||
pointer ret;
|
||||
|
||||
#ifdef SHM_RDONLY
|
||||
if (xf86shmflg & XF86SHM_RDONLY) shmflg |= SHM_RDONLY;
|
||||
#endif
|
||||
|
@ -1899,13 +1918,25 @@ xf86shmat(int id, char *addr, int xf86shmflg)
|
|||
if (xf86shmflg & XF86SHM_REMAP) shmflg |= SHM_REMAP;
|
||||
#endif
|
||||
|
||||
return shmat(id,addr,shmflg);
|
||||
ret = shmat(id,addr,shmflg);
|
||||
|
||||
if (ret == (pointer) -1)
|
||||
xf86errno = xf86GetErrno();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
xf86shmdt(char *addr)
|
||||
{
|
||||
return shmdt(addr);
|
||||
int ret;
|
||||
|
||||
ret = shmdt(addr);
|
||||
|
||||
if (ret == -1)
|
||||
xf86errno = xf86GetErrno();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1915,7 +1946,8 @@ int
|
|||
xf86shmctl(int id, int xf86cmd, pointer buf)
|
||||
{
|
||||
int cmd;
|
||||
|
||||
int ret;
|
||||
|
||||
switch (xf86cmd) {
|
||||
case XF86IPC_RMID:
|
||||
cmd = IPC_RMID;
|
||||
|
@ -1924,32 +1956,44 @@ xf86shmctl(int id, int xf86cmd, pointer buf)
|
|||
return 0;
|
||||
}
|
||||
|
||||
return shmctl(id, cmd, buf);
|
||||
ret = shmctl(id, cmd, buf);
|
||||
|
||||
if (ret == -1)
|
||||
xf86errno = xf86GetErrno();
|
||||
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
|
||||
int
|
||||
xf86shmget(xf86key_t key, int size, int xf86shmflg)
|
||||
{
|
||||
return -1;
|
||||
xf86errno = ENOSYS;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *
|
||||
xf86shmat(int id, char *addr, int xf86shmflg)
|
||||
{
|
||||
xf86errno = ENOSYS;
|
||||
|
||||
return (char *)-1;
|
||||
}
|
||||
|
||||
int
|
||||
xf86shmctl(int id, int xf86cmd, pointer buf)
|
||||
{
|
||||
xf86errno = ENOSYS;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
xf86shmdt(char *addr)
|
||||
{
|
||||
xf86errno = ENOSYS;
|
||||
|
||||
return -1;
|
||||
}
|
||||
#endif /* HAVE_SYSV_IPC */
|
||||
|
@ -1979,7 +2023,7 @@ xf86setjmp(xf86jmp_buf env)
|
|||
int
|
||||
xf86setjmp0(xf86jmp_buf env)
|
||||
{
|
||||
FatalError("setjmp: type 0 called instead of type %d\n", xf86getjmptype());
|
||||
FatalError("setjmp: type 0 called instead of type %d", xf86getjmptype());
|
||||
}
|
||||
|
||||
#if !defined(__GLIBC__) || (__GLIBC__ < 2) /* libc5 */
|
||||
|
@ -1998,7 +2042,7 @@ xf86setjmp1(xf86jmp_buf env, int arg2)
|
|||
int
|
||||
xf86setjmp1(xf86jmp_buf env, int arg2)
|
||||
{
|
||||
FatalError("setjmp: type 1 called instead of type %d\n", xf86getjmptype());
|
||||
FatalError("setjmp: type 1 called instead of type %d", xf86getjmptype());
|
||||
}
|
||||
|
||||
#endif /* HAS_GLIBC_SIGSETJMP */
|
||||
|
@ -2012,7 +2056,7 @@ xf86setjmp1_arg2()
|
|||
int
|
||||
xf86setjmperror(xf86jmp_buf env)
|
||||
{
|
||||
FatalError("setjmp: don't know how to handle setjmp() type %d\n",
|
||||
FatalError("setjmp: don't know how to handle setjmp() type %d",
|
||||
xf86getjmptype());
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ VBEExtendedInit(xf86Int10InfoPtr pInt, int entityIndex, int Flags)
|
|||
goto error;
|
||||
|
||||
xf86DrvMsg(screen,X_INFO,"initializing int10\n");
|
||||
pInt = xf86InitInt10(entityIndex);
|
||||
pInt = xf86ExtendedInitInt10(entityIndex,Flags);
|
||||
if (!pInt)
|
||||
goto error;
|
||||
init_int10 = TRUE;
|
||||
|
|
Loading…
Reference in New Issue