[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#382419: New problems in same package



severity 382419 serious
thanks

It seems like it is the MTRR support that cause the failure. I have
now corrected the makedepend program in order to not segfault. For
some reason it did a division by zero, and I do not know why. That
is worked around, by checking the divisor first...

However this show that the problem may still be in the linux-kernel-headers
package as it now fail while building instead, as MTRR support seem to
be broken.

Here is the logs about the problem. Please help.

Have attached the lnx_video.c file as well.

gcc -c -O2 -fno-strength-reduce -ansi -pedantic -Wall -Wpointer-arith -Wundef    -fno-merge-constants -I../../../../../../programs/Xserver/hw/xfree86/common -I../../../../../../programs/Xserver/hw/xfree86/os-support -I. -I../../../../../../programs/Xserver/include            -I../../../../../../exports/include/X11 -I../../../../../../include/extensions -I../../../../../../programs/Xserver/hw/xfree86/os-support/shared  -I../../../../../.. -I../../../../../../exports/include -I/usr/X11R6/include  -Dlinux -D__x86_64__ -D_POSIX_C_SOURCE=199309L                              -D_POSIX_SOURCE -D_XOPEN_SOURCE                                 -D_BSD_SOURCE -D_SVID_SOURCE                             -D_GNU_SOURCE                           -DSHAPE -DXINPUT -DXKB -DLBX -DXAPPGROUP       -DXCSECURITY -DTOGCUP   -DXF86BIGFONT -DDPMSExtension     -DPANORAMIX    -DRENDER -DRANDR -DGCCUSESGAS -DAVOID_GLYPHBLT -DPIXPRIV -DSINGLEDEPTH                                 -DXFreeXDGA -DXvExtension                               -DXFree86LOADER  -DXFree86Server                                -DXF86VIDMODE                           -DXvMCExtension                                                                 -DSMART_SCHEDULE                                -DBUILDDEBUG -DXResExtension                            -DX_BYTE_ORDER=X_LITTLE_ENDIAN -D_XSERVER64 -DNDEBUG  -DFUNCPROTO=15 -DNARROWPROTO   -DHAS_MTRR_SUPPORT -DUSESTDRES -DHAVE_SYSV_IPC   lnx_video.cIn file included from /usr/include/linux/sem.h:4,
                 from /usr/include/linux/compat.h:13,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/linux/ipc.h:11: error: expected specifier-qualifier-list before '__kernel_key_t'
In file included from /usr/include/asm/ipcbuf.h:8,
                 from /usr/include/linux/ipc.h:21,
                 from /usr/include/linux/sem.h:4,
                 from /usr/include/linux/compat.h:13,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/asm-x86_64/ipcbuf.h:16: error: expected specifier-qualifier-list before '__kernel_key_t'
In file included from /usr/include/asm-x86_64/atomic.h:435,
                 from /usr/include/asm/atomic.h:8,
                 from /usr/include/linux/sem.h:5,
                 from /usr/include/linux/compat.h:13,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/asm-generic/atomic.h:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'long'
/usr/include/asm-generic/atomic.h:34: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/asm-generic/atomic.h:41: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/asm-generic/atomic.h:48: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/asm-generic/atomic.h:55: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/asm-generic/atomic.h:62: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
In file included from /usr/include/linux/compat.h:13,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/linux/sem.h:26: error: expected specifier-qualifier-list before '__kernel_time_t'
In file included from /usr/include/asm/sembuf.h:8,
                 from /usr/include/linux/sem.h:36,
                 from /usr/include/linux/compat.h:13,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/asm-x86_64/sembuf.h:16: error: expected specifier-qualifier-list before '__kernel_time_t'
In file included from /usr/include/asm/msr.h:8,
                 from /usr/include/asm-x86_64/timex.h:10,
                 from /usr/include/asm/timex.h:8,
                 from /usr/include/linux/timex.h:61,
                 from /usr/include/linux/sched.h:11,
                 from /usr/include/asm-x86_64/compat.h:8,
                 from /usr/include/asm/compat.h:8,
                 from /usr/include/linux/compat.h:15,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/asm-x86_64/msr.h:82: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/asm-x86_64/msr.h:94: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/asm-x86_64/msr.h:108: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
/usr/include/asm-x86_64/msr.h:118: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
/usr/include/asm-x86_64/msr.h:128: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
/usr/include/asm-x86_64/msr.h:138: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
In file included from /usr/include/asm/bitops.h:8,
                 from /usr/include/linux/bitops.h:9,
                 from /usr/include/linux/thread_info.h:20,
                 from /usr/include/linux/preempt.h:10,
                 from /usr/include/linux/seqlock.h:31,
                 from /usr/include/asm-x86_64/vsyscall.h:4,
                 from /usr/include/asm/vsyscall.h:8,
                 from /usr/include/asm-x86_64/timex.h:11,
                 from /usr/include/asm/timex.h:8,
                 from /usr/include/linux/timex.h:61,
                 from /usr/include/linux/sched.h:11,
                 from /usr/include/asm-x86_64/compat.h:8,
                 from /usr/include/asm/compat.h:8,
                 from /usr/include/linux/compat.h:15,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/asm-x86_64/bitops.h:263: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
/usr/include/asm-x86_64/bitops.h:295: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/asm-x86_64/bitops.h:305: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
In file included from /usr/include/linux/thread_info.h:20,
                 from /usr/include/linux/preempt.h:10,
                 from /usr/include/linux/seqlock.h:31,
                 from /usr/include/asm-x86_64/vsyscall.h:4,
                 from /usr/include/asm/vsyscall.h:8,
                 from /usr/include/asm-x86_64/timex.h:11,
                 from /usr/include/asm/timex.h:8,
                 from /usr/include/linux/timex.h:61,
                 from /usr/include/linux/sched.h:11,
                 from /usr/include/asm-x86_64/compat.h:8,
                 from /usr/include/asm/compat.h:8,
                 from /usr/include/linux/compat.h:15,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/linux/bitops.h:29: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
/usr/include/linux/bitops.h:40: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__u32'
/usr/include/linux/bitops.h:51: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__u32'
/usr/include/linux/bitops.h:56: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
In file included from /usr/include/asm-x86_64/vsyscall.h:4,
                 from /usr/include/asm/vsyscall.h:8,
                 from /usr/include/asm-x86_64/timex.h:11,
                 from /usr/include/asm/timex.h:8,
                 from /usr/include/linux/timex.h:61,
                 from /usr/include/linux/sched.h:11,
                 from /usr/include/asm-x86_64/compat.h:8,
                 from /usr/include/asm/compat.h:8,
                 from /usr/include/linux/compat.h:15,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/linux/seqlock.h:50: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/seqlock.h:57: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/seqlock.h:64: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/seqlock.h:76: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
/usr/include/linux/seqlock.h:91: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/seqlock.h:113: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
/usr/include/linux/seqlock.h:125: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/seqlock.h:136: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/seqlock.h:142: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
In file included from /usr/include/asm/system.h:8,
                 from /usr/include/asm-x86_64/timex.h:13,
                 from /usr/include/asm/timex.h:8,
                 from /usr/include/linux/timex.h:61,
                 from /usr/include/linux/sched.h:11,
                 from /usr/include/asm-x86_64/compat.h:8,
                 from /usr/include/asm/compat.h:8,
                 from /usr/include/linux/compat.h:15,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/asm-x86_64/system.h:209: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/asm-x86_64/system.h:221: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
/usr/include/asm-x86_64/system.h:260: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
In file included from /usr/include/asm/sigcontext.h:8,
                 from /usr/include/asm-x86_64/processor.h:13,
                 from /usr/include/asm/processor.h:8,
                 from /usr/include/asm-x86_64/timex.h:14,
                 from /usr/include/asm/timex.h:8,
                 from /usr/include/linux/timex.h:61,
                 from /usr/include/linux/sched.h:11,
                 from /usr/include/asm-x86_64/compat.h:8,
                 from /usr/include/asm/compat.h:8,
                 from /usr/include/linux/compat.h:15,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/asm-x86_64/sigcontext.h:10: error: redefinition of 'struct _fpstate'
/usr/include/asm-x86_64/sigcontext.h:24: error: redefinition of 'struct sigcontext'
In file included from /usr/include/asm/current.h:8,
                 from /usr/include/asm-x86_64/processor.h:18,
                 from /usr/include/asm/processor.h:8,
                 from /usr/include/asm-x86_64/timex.h:14,
                 from /usr/include/asm/timex.h:8,
                 from /usr/include/linux/timex.h:61,
                 from /usr/include/linux/sched.h:11,
                 from /usr/include/asm-x86_64/compat.h:8,
                 from /usr/include/asm/compat.h:8,
                 from /usr/include/linux/compat.h:15,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/asm-x86_64/current.h:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'struct'
In file included from /usr/include/linux/cpumask.h:86,
                 from /usr/include/asm-x86_64/processor.h:23,
                 from /usr/include/asm/processor.h:8,
                 from /usr/include/asm-x86_64/timex.h:14,
                 from /usr/include/asm/timex.h:8,
                 from /usr/include/linux/timex.h:61,
                 from /usr/include/linux/sched.h:11,
                 from /usr/include/asm-x86_64/compat.h:8,
                 from /usr/include/asm/compat.h:8,
                 from /usr/include/linux/compat.h:15,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/linux/bitmap.h:126: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/bitmap.h:136: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/bitmap.h:146: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/bitmap.h:157: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/bitmap.h:166: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/bitmap.h:175: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/bitmap.h:184: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/bitmap.h:193: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/bitmap.h:202: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/bitmap.h:211: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/bitmap.h:220: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/bitmap.h:229: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/bitmap.h:237: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/bitmap.h:245: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/bitmap.h:250: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/bitmap.h:259: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
In file included from /usr/include/asm-x86_64/processor.h:23,
                 from /usr/include/asm/processor.h:8,
                 from /usr/include/asm-x86_64/timex.h:14,
                 from /usr/include/asm/timex.h:8,
                 from /usr/include/linux/timex.h:61,
                 from /usr/include/linux/sched.h:11,
                 from /usr/include/asm-x86_64/compat.h:8,
                 from /usr/include/asm/compat.h:8,
                 from /usr/include/linux/compat.h:15,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/linux/cpumask.h:88: error: expected specifier-qualifier-list before 'DECLARE_BITMAP'
/usr/include/linux/cpumask.h:92: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/cpumask.h:98: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/cpumask.h:104: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/cpumask.h:110: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/cpumask.h:119: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/cpumask.h:125: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/cpumask.h:132: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/cpumask.h:139: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/cpumask.h:147: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/cpumask.h:154: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/cpumask.h:161: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/cpumask.h:168: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/cpumask.h:175: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/cpumask.h:182: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/cpumask.h:188: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/cpumask.h:194: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/cpumask.h:201: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/cpumask.h:209: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/linux/cpumask.h:270: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/cpumask.h:278: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/cpumask.h:286: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/cpumask.h:293: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/cpumask.h:300: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/usr/include/linux/cpumask.h:308: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
In file included from /usr/include/asm/processor.h:8,
                 from /usr/include/asm-x86_64/timex.h:14,
                 from /usr/include/asm/timex.h:8,
                 from /usr/include/linux/timex.h:61,
                 from /usr/include/linux/sched.h:11,
                 from /usr/include/asm-x86_64/compat.h:8,
                 from /usr/include/asm/compat.h:8,
                 from /usr/include/linux/compat.h:15,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/asm-x86_64/processor.h:145: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/asm-x86_64/processor.h:155: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/asm-x86_64/processor.h:191: error: expected specifier-qualifier-list before 'u16'
/usr/include/asm-x86_64/processor.h:209: error: expected specifier-qualifier-list before 'u32'
/usr/include/asm-x86_64/processor.h:266: error: expected specifier-qualifier-list before 'u64'
/usr/include/asm-x86_64/processor.h:384: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/asm-x86_64/processor.h:390: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/asm-x86_64/processor.h:399: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/asm-x86_64/processor.h:405: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/asm-x86_64/processor.h:446: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/asm-x86_64/processor.h:451: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/usr/include/asm-x86_64/processor.h:460: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
In file included from /usr/include/asm/timex.h:8,
                 from /usr/include/linux/timex.h:61,
                 from /usr/include/linux/sched.h:11,
                 from /usr/include/asm-x86_64/compat.h:8,
                 from /usr/include/asm/compat.h:8,
                 from /usr/include/linux/compat.h:15,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/asm-x86_64/timex.h:21: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'cycles_t'
/usr/include/asm-x86_64/timex.h:30: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'cycles_t'
In file included from /usr/include/linux/jiffies.h:4,
                 from /usr/include/linux/sched.h:12,
                 from /usr/include/asm-x86_64/compat.h:8,
                 from /usr/include/asm/compat.h:8,
                 from /usr/include/linux/compat.h:15,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/linux/calc64.h:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
/usr/include/linux/calc64.h:35: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'long'
In file included from /usr/include/linux/sched.h:12,
                 from /usr/include/asm-x86_64/compat.h:8,
                 from /usr/include/asm/compat.h:8,
                 from /usr/include/linux/compat.h:15,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/linux/jiffies.h:81: error: expected ',' or ';' before 'jiffies_64'
/usr/include/linux/jiffies.h:87: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u64'
/usr/include/linux/jiffies.h:252: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
In file included from /usr/include/linux/sched.h:12,
                 from /usr/include/asm-x86_64/compat.h:8,
                 from /usr/include/asm/compat.h:8,
                 from /usr/include/linux/compat.h:15,
                 from /usr/include/asm-x86_64/mtrr.h:28,
                 from /usr/include/asm/mtrr.h:8,
                 from lnx_video.c:48:
/usr/include/linux/jiffies.h:256:47: error: division by zero in #if
/usr/include/linux/jiffies.h:263: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
/usr/include/linux/jiffies.h:267:47: error: division by zero in #if
/usr/include/linux/jiffies.h:274: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
/usr/include/linux/jiffies.h:280:47: error: division by zero in #if
/usr/include/linux/jiffies.h:287: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned'
/usr/include/linux/jiffies.h:293:47: error: division by zero in #if
/usr/include/linux/jiffies.h: In function 'timespec_to_jiffies':
/usr/include/linux/jiffies.h:317: error: 'NSEC_PER_SEC' undeclared (first use in this function)
/usr/include/linux/jiffies.h:317: error: (Each undeclared identifier is reported only once
/usr/include/linux/jiffies.h:317: error: for each function it appears in.)
/usr/include/linux/jiffies.h:321: error: expected ')' before 'sec'
/usr/include/linux/jiffies.h:322: error: expected ')' before 'nsec'
/usr/include/linux/jiffies.h: In function 'jiffies_to_timespec':
/usr/include/linux/jiffies.h:334: error: expected ';' before 'nsec'

and so on ... Full build log (several MB) can be found on
http://buildd.debian.org/fetch.php?&pkg=vnc4&ver=4.1.1%2BX4.3.0-15&arch=amd64&stamp=1157578499&file=log&as=raw

Regards,

// Ola

-- 
 --------------------- Ola Lundqvist ---------------------------
/  opal@debian.org                     Annebergsslingan 37      \
|  opal@lysator.liu.se                 654 65 KARLSTAD          |
|  +46 (0)54-10 14 30                  +46 (0)70-332 1551       |
|  http://www.opal.dhs.org             UIN/icq: 4912500         |
\  gpg/f.p.: 7090 A92B 18FE 7994 0C36  4FE4 18A1 B1CF 0FE5 3DD9 /
 ---------------------------------------------------------------
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c,v 3.64 2003/02/17 15:29:22 dawes Exp $ */
/*
 * Copyright 1992 by Orest Zborowski <obz@Kodak.com>
 * Copyright 1993 by David Wexelblat <dwex@goblin.org>
 *
 * 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, and that the names of Orest Zborowski and David Wexelblat
 * not be used in advertising or publicity pertaining to distribution of
 * the software without specific, written prior permission.  Orest Zborowski
 * and David Wexelblat make no representations about the suitability of this
 * software for any purpose.  It is provided "as is" without express or
 * implied warranty.
 *
 * OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD
 * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT 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.
 *
 */
/* $XConsortium: lnx_video.c /main/9 1996/10/19 18:06:34 kaleb $ */

#ifdef __x86_64__
#ifndef BITS_PER_LONG
#define BITS_PER_LONG 64
#endif
#endif

#include "X.h"
#include "input.h"
#include "scrnintstr.h"

#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
#include "xf86OSpriv.h"
#include "lnx.h"
#ifdef __alpha__
#include "xf86Axp.h"
#endif

#ifdef HAS_MTRR_SUPPORT
#include <asm/mtrr.h>
#endif

#ifndef MAP_FAILED
#define MAP_FAILED ((void *)-1)
#endif

static Bool ExtendedEnabled = FALSE;

#ifdef __ia64__

#include "compiler.h"
#include <sys/io.h>

#elif !defined(__powerpc__) && \
      !defined(__mc68000__) && \
      !defined(__sparc__) && \
      !defined(__mips__)

/*
 * Due to conflicts with "compiler.h", don't rely on <sys/io.h> to declare
 * these.
 */
extern int ioperm(unsigned long __from, unsigned long __num, int __turn_on);
extern int iopl(int __level);

#endif

#ifdef __alpha__

# ifdef LIBC_IS_FIXED
extern void sethae(unsigned long hae);
# else
#  include <unistd.h>
#  define sethae(x) syscall(301,x);
# endif

/* define to test the Sparse addressing on a non-Jensen */
# ifdef TEST_JENSEN_CODE 
#  define isJensen (1)
# else
#  define isJensen (axpSystem == JENSEN)
# endif

# define BUS_BASE bus_base

#else 

#define BUS_BASE (0)

#endif /*  __alpha__ */

/***************************************************************************/
/* Video Memory Mapping section                                            */
/***************************************************************************/

static pointer mapVidMem(int, unsigned long, unsigned long, int);
static void unmapVidMem(int, pointer, unsigned long);
#if defined (__alpha__) 
static pointer mapVidMemSparse(int, unsigned long, unsigned long, int);
extern axpDevice lnxGetAXP(void);
static void unmapVidMemSparse(int, pointer, unsigned long);
# if defined(JENSEN_SUPPORT)
static pointer mapVidMemJensen(int, unsigned long, unsigned long, int);
static void unmapVidMemJensen(int, pointer, unsigned long);
# endif
static axpDevice axpSystem = -1;
static Bool needSparse;
static unsigned long hae_thresh;
static unsigned long hae_mask;
static unsigned long bus_base;
static unsigned long sparse_size;
#endif

#ifdef HAS_MTRR_SUPPORT

#define SPLIT_WC_REGIONS 1

static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType);
static void undoWC(int, pointer);

/* The file desc for /proc/mtrr. Once opened, left opened, and the mtrr
   driver will clean up when we exit. */
#define MTRR_FD_UNOPENED (-1)	/* We have yet to open /proc/mtrr */
#define MTRR_FD_PROBLEM (-2)	/* We tried to open /proc/mtrr, but had
				   a problem. */
static int mtrr_fd = MTRR_FD_UNOPENED;

/* Open /proc/mtrr. FALSE on failure. Will always fail on Linux 2.0, 
   and will fail on Linux 2.2 with MTRR support configured out,
   so verbosity should be chosen appropriately. */
static Bool
mtrr_open(int verbosity)
{
	/* Only report absence of /proc/mtrr once. */
	static Bool warned = FALSE;

	char **fn;
	static char *mtrr_files[] = {
		"/dev/cpu/mtrr",	/* Possible future name */
		"/proc/mtrr",		/* Current name */
		NULL
	};

	if (mtrr_fd == MTRR_FD_UNOPENED) { 
		/* So open it. */
		for (fn = mtrr_files; mtrr_fd < 0 && *fn; fn++)
			mtrr_fd = open(*fn, O_WRONLY);

		if (mtrr_fd < 0)
			mtrr_fd = MTRR_FD_PROBLEM;
	}

	if (mtrr_fd == MTRR_FD_PROBLEM) {
		/* To make sure we only ever warn once, need to check
		   verbosity outside xf86MsgVerb */
		if (!warned && verbosity <= xf86GetVerbosity()) {
			xf86MsgVerb(X_WARNING, verbosity,
				  "System lacks support for changing MTRRs\n");
			warned = TRUE;
		}

		return FALSE;
	}
	else
		return TRUE;
}

/*
 * We maintain a list of WC regions for each physical mapping so they can
 * be undone when unmapping.
 */

struct mtrr_wc_region {
	struct mtrr_sentry	sentry;
	Bool			added;		/* added WC or removed it */
	struct mtrr_wc_region *	next;
};

static struct mtrr_wc_region *
mtrr_cull_wc_region(int screenNum, unsigned long base, unsigned long size,
		      MessageType from)
{
	/* Some BIOS writers thought that setting wc over the mmio
	   region of a graphics devices was a good idea. Try to fix
	   it. */

	struct mtrr_gentry gent;
	char buf[20];
	struct mtrr_wc_region *wcreturn = NULL, *wcr;

	/* Linux 2.0 users should not get a warning without -verbose */
	if (!mtrr_open(2))
		return NULL;

	for (gent.regnum = 0; 
	     ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0;
	     gent.regnum++) {
		if (gent.type != MTRR_TYPE_WRCOMB
		    || gent.base + gent.size <= base
		    || base + size <= gent.base)
			continue;

		/* Found an overlapping region. Delete it. */
		
		wcr = xalloc(sizeof(*wcr));
		if (!wcr)
			return NULL;
		wcr->sentry.base = gent.base;
		wcr->sentry.size = gent.size;
		wcr->sentry.type = MTRR_TYPE_WRCOMB;
		wcr->added = FALSE;
		
		/* There is now a nicer ioctl-based way to do this,
		   but it isn't in current kernels. */
		snprintf(buf, sizeof(buf), "disable=%u\n", gent.regnum);

		if (write(mtrr_fd, buf, strlen(buf)) >= 0) {
			xf86DrvMsg(screenNum, from,
				   "Removed MMIO write-combining range "
				   "(0x%lx,0x%lx)\n",
				   gent.base, gent.size);
			wcr->next = wcreturn;
			wcreturn = wcr;
		} else {
			xfree(wcr);
			xf86DrvMsgVerb(screenNum, X_WARNING, 0,
				   "Failed to remove MMIO "
				   "write-combining range (0x%lx,0x%lx)\n",
				   gent.base, gent.size);
		}
	}
	return wcreturn;
}


static struct mtrr_wc_region *
mtrr_add_wc_region(int screenNum, unsigned long base, unsigned long size,
		   MessageType from)
{
	struct mtrr_wc_region *wcr;

	/* Linux 2.0 should not warn, unless the user explicitly asks for
	   WC. */
	if (!mtrr_open(from == X_CONFIG ? 0 : 2))
		return NULL;

	wcr = xalloc(sizeof(*wcr));
	if (!wcr)
		return NULL;

	wcr->sentry.base = base;
	wcr->sentry.size = size;
	wcr->sentry.type = MTRR_TYPE_WRCOMB;
	wcr->added = TRUE;
	wcr->next = NULL;

#if SPLIT_WC_REGIONS
	/*
	 * Splits up the write-combining region if it is not aligned on a
 	 * size boundary.
	 */

	{
	    unsigned long lbase, d_size = 1;
	    unsigned long n_size = size;
	    unsigned long n_base = base;

	    for (lbase = n_base, d_size = 1; !(lbase & 1);
		 lbase = lbase >> 1, d_size <<= 1);
	    while (d_size > n_size)
		d_size = d_size >> 1;
#ifdef DEBUG
	    ErrorF("WC_BASE: 0x%lx WC_END: 0x%lx\n",base,base+d_size-1);
#endif
	    n_base += d_size;
	    n_size -= d_size;
	    if (n_size) {
		xf86DrvMsgVerb(screenNum,X_INFO,3,"Splitting WC range: "
			       "base: 0x%lx, size: 0x%lx\n",base,size);
		wcr->next = mtrr_add_wc_region(screenNum, n_base, n_size,from);
	    }
	    wcr->sentry.size = d_size;
	} 
	
	/*****************************************************************/
#endif /* SPLIT_WC_REGIONS */

	if (ioctl(mtrr_fd, MTRRIOC_ADD_ENTRY, &wcr->sentry) >= 0) {
		/* Avoid printing on every VT switch */
		if (xf86ServerIsInitialising()) {
			xf86DrvMsg(screenNum, from,
				   "Write-combining range (0x%lx,0x%lx)\n",
				   base, size);
		}
		return wcr;
	}
	else {
		xfree(wcr);
		
		/* Don't complain about the VGA region: MTRR fixed
		   regions aren't currently supported, but might be in
		   the future. */
		if ((unsigned long)base >= 0x100000) {
			xf86DrvMsgVerb(screenNum, X_WARNING, 0,
				"Failed to set up write-combining range "
				"(0x%lx,0x%lx)\n", base, size);
		}
		return NULL;
	}
}

static void
mtrr_undo_wc_region(int screenNum, struct mtrr_wc_region *wcr)
{
	struct mtrr_wc_region *p, *prev;

	if (mtrr_fd > 0) {
		p = wcr;
		while (p) {
			if (p->added)
				ioctl(mtrr_fd, MTRRIOC_DEL_ENTRY, &p->sentry);
			prev = p;
			p = p->next;
			xfree(prev);
		}
	}
}

static pointer
setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
      MessageType from)
{
	if (enable)
		return mtrr_add_wc_region(screenNum, base, size, from);
	else
		return mtrr_cull_wc_region(screenNum, base, size, from);
}

static void
undoWC(int screenNum, pointer regioninfo)
{
	mtrr_undo_wc_region(screenNum, regioninfo);
}

#endif /* HAS_MTRR_SUPPORT */

void
xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
	pVidMem->linearSupported = TRUE;
#ifdef __alpha__
	if (axpSystem == -1) {
	  axpSystem = lnxGetAXP();
	  if ((needSparse = (_bus_base_sparse() > 0))) {
	    hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
	    hae_mask = xf86AXPParams[axpSystem].hae_mask;
	    sparse_size = xf86AXPParams[axpSystem].size;
	  }
	  bus_base = _bus_base();
	}
	if (isJensen) {
# ifndef JENSEN_SUPPORT
	  FatalError("Jensen is not supported any more\n"
		     "If you are intereseted in fixing Jensen support\n"
		     "please contact xfree86@xfree86.org\n");
# else
	  xf86Msg(X_INFO,"Machine type is Jensen\n");
	  pVidMem->mapMem = mapVidMemJensen;
	  pVidMem->unmapMem = unmapVidMemJensen;
# endif /* JENSEN_SUPPORT */
	} else if (needSparse) {
	  xf86Msg(X_INFO,"Machine needs sparse mapping\n");
	  pVidMem->mapMem = mapVidMemSparse;
	  pVidMem->unmapMem = unmapVidMemSparse;
	} else {
	  xf86Msg(X_INFO,"Machine type has 8/16 bit access\n");
	  pVidMem->mapMem = mapVidMem;
	  pVidMem->unmapMem = unmapVidMem;
	}	
#else
	pVidMem->mapMem = mapVidMem;
	pVidMem->unmapMem = unmapVidMem;
#endif /* __alpha__ */


#ifdef HAS_MTRR_SUPPORT
	pVidMem->setWC = setWC;
	pVidMem->undoWC = undoWC;
#endif
	pVidMem->initialised = TRUE;
}

#ifdef __sparc__
/* Basically, you simply cannot do this on Sparc.  You have to do something portable
 * like use /dev/fb* or mmap() on /proc/bus/pci/X/Y nodes. -DaveM
 */
static pointer mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
	return NULL;
}
#else
static pointer
mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
    pointer base;
    int fd;
    int mapflags = MAP_SHARED; 
    memType realBase, alignOff;

    realBase = Base & ~(getpagesize() - 1);
    alignOff = Base - realBase;
#ifdef DEBUG
    ErrorF("base: %lx, realBase: %lx, alignOff: %lx \n",
	   Base,realBase,alignOff);
#endif
    
#if defined(__ia64__)
#ifndef MAP_WRITECOMBINED
#define MAP_WRITECOMBINED 0x00010000
#endif
#ifndef MAP_NONCACHED
#define MAP_NONCACHED 0x00020000
#endif
    if(flags & VIDMEM_FRAMEBUFFER) 
        mapflags |= MAP_WRITECOMBINED; 
    else
        mapflags |= MAP_NONCACHED; 
#endif

#if defined(__ia64__)
    /* this will disappear when people upgrade their kernels */
    if ((fd = open(DEV_MEM, O_RDWR|O_SYNC)) < 0) 
#else
    if ((fd = open(DEV_MEM, O_RDWR)) < 0)
#endif
    {
	FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
		   strerror(errno));
    }
    /* This requires linux-0.99.pl10 or above */
    base = mmap((caddr_t)0, Size + alignOff,
  		PROT_READ|PROT_WRITE,
  		mapflags, fd,
 		(off_t)(off_t)realBase  + BUS_BASE);
    close(fd);
    if (base == MAP_FAILED) {
        FatalError("xf86MapVidMem: Could not mmap framebuffer"
		   " (0x%08x,0x%x) (%s)\n", Base, Size,
		   strerror(errno));
    }
#ifdef DEBUG
    ErrorF("base: %lx aligned base: %lx\n",base, base + alignOff);
#endif
    return (char *)base + alignOff;
}
#endif /* !(__sparc__) */
    
static void
unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
    memType alignOff = (memType)Base 
	- ((memType)Base & ~(getpagesize() - 1));
    
#ifdef DEBUG
    ErrorF("alignment offset: %lx\n",alignOff);
#endif
    munmap((caddr_t)((memType)Base - alignOff), (Size + alignOff));
}


/***************************************************************************/
/* I/O Permissions section                                                 */
/***************************************************************************/

#if defined(__powerpc__)
volatile unsigned char *ioBase = NULL;

#ifndef __NR_pciconfig_iobase
#define __NR_pciconfig_iobase	200
#endif

#endif

void
xf86EnableIO(void)
{
#if defined(__powerpc__)
	int fd;
	unsigned int ioBase_phys;
#endif

	if (ExtendedEnabled)
		return;

#if defined(__powerpc__)
	ioBase_phys = syscall(__NR_pciconfig_iobase, 2, 0, 0);

	fd = open("/dev/mem", O_RDWR);
	if (ioBase == NULL) {
		ioBase = (volatile unsigned char *)mmap(0, 0x20000,
				PROT_READ|PROT_WRITE, MAP_SHARED, fd,
				ioBase_phys);
/* Should this be fatal or just a warning? */
#if 0
		if (ioBase == MAP_FAILED) {
			FatalError(
			    "xf86EnableIOPorts: Failed to map iobase (%s)\n",
			    strerror(errno));
		}
#endif
	}
	close(fd);
#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__)
	if (ioperm(0, 1024, 1) || iopl(3))
		FatalError("xf86EnableIOPorts: Failed to set IOPL for I/O\n");
# if !defined(__alpha__)
	ioperm(0x40,4,0); /* trap access to the timer chip */
	ioperm(0x60,4,0); /* trap access to the keyboard controller */
# endif
#endif
	ExtendedEnabled = TRUE;

	return;
}

void
xf86DisableIO(void)
{
	if (!ExtendedEnabled)
		return;
#if defined(__powerpc__)
	munmap(ioBase, 0x20000);
	ioBase = NULL;
#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__)
	iopl(0);
	ioperm(0, 1024, 0);
#endif
	ExtendedEnabled = FALSE;

	return;
}


/***************************************************************************/
/* Interrupt Handling section                                              */
/***************************************************************************/

/* XXX The #ifdefs should be made simpler. */

Bool
xf86DisableInterrupts()
{
#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__sh__) && !defined(__hppa__)
	if (!ExtendedEnabled)
	    if (iopl(3) || ioperm(0, 1024, 1))
			return (FALSE);
#endif
#if defined(__alpha__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__) || defined(__mips__) || defined(__arm__) || defined(__sh__) || defined(__ia64__) || defined(__hppa__)
#else
# ifdef __GNUC__
#  if defined(__ia64__)
#   if 0
	__asm__ __volatile__ (";; rsm psr.i;; srlz.d" ::: "memory");
#   endif
#  else
      __asm__ __volatile__("cli");
#  endif
# else
	asm("cli");
# endif
#endif
#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__ia64__) && !defined(__hppa__)
	if (!ExtendedEnabled) {
	    iopl(0);
	    ioperm(0, 1024, 0);
	}
	
#endif
	return (TRUE);
}

void
xf86EnableInterrupts()
{
#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__sh__) && !defined(__hppa__)
	if (!ExtendedEnabled)
	    if (iopl(3) || ioperm(0, 1024, 1))
			return;
#endif
#if defined(__alpha__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__) || defined(__mips__) || defined(__arm__) || defined(__sh__) || defined(__ia64__) || defined(__hppa__)
#else
# ifdef __GNUC__
#  if defined(__ia64__)
#   if 0
	__asm__ __volatile__ (";; ssm psr.i;; srlz.d" ::: "memory");
#   endif
#  else
      __asm__ __volatile__("sti");
#  endif
# else
	asm("sti");
# endif
#endif
#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__ia64__) && !defined(__hppa__)
	if (!ExtendedEnabled) {
	    iopl(0);
	    ioperm(0, 1024, 0);
	}
#endif
	return;
}

#if defined (__alpha__)

#define vuip    volatile unsigned int *

extern int readDense8(pointer Base, register unsigned long Offset);
extern int readDense16(pointer Base, register unsigned long Offset);
extern int readDense32(pointer Base, register unsigned long Offset);
extern void
writeDenseNB8(int Value, pointer Base, register unsigned long Offset);
extern void
writeDenseNB16(int Value, pointer Base, register unsigned long Offset);
extern void
writeDenseNB32(int Value, pointer Base, register unsigned long Offset);
extern void
writeDense8(int Value, pointer Base, register unsigned long Offset);
extern void
writeDense16(int Value, pointer Base, register unsigned long Offset);
extern void
writeDense32(int Value, pointer Base, register unsigned long Offset);

static int readSparse8(pointer Base, register unsigned long Offset);
static int readSparse16(pointer Base, register unsigned long Offset);
static int readSparse32(pointer Base, register unsigned long Offset);
static void
writeSparseNB8(int Value, pointer Base, register unsigned long Offset);
static void
writeSparseNB16(int Value, pointer Base, register unsigned long Offset);
static void
writeSparseNB32(int Value, pointer Base, register unsigned long Offset);
static void
writeSparse8(int Value, pointer Base, register unsigned long Offset);
static void
writeSparse16(int Value, pointer Base, register unsigned long Offset);
static void
writeSparse32(int Value, pointer Base, register unsigned long Offset);

#define DENSE_BASE	0x2ff00000000UL
#define SPARSE_BASE	0x30000000000UL

static unsigned long msb_set = 0;

static pointer
mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
    int fd;
    unsigned long ret, rets = 0;

    static Bool was_here = FALSE;

    if (!was_here) {
      was_here = TRUE;

      xf86WriteMmio8 = writeSparse8;
      xf86WriteMmio16 = writeSparse16;
      xf86WriteMmio32 = writeSparse32;
      xf86WriteMmioNB8 = writeSparseNB8;
      xf86WriteMmioNB16 = writeSparseNB16;
      xf86WriteMmioNB32 = writeSparseNB32;
      xf86ReadMmio8 = readSparse8;
      xf86ReadMmio16 = readSparse16;
      xf86ReadMmio32 = readSparse32;
    }
	
    if ((fd = open(DEV_MEM, O_RDWR)) < 0) {
        FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
		   strerror(errno));
    }

#if 0
    xf86Msg(X_INFO,"mapVidMemSparse: try Base 0x%lx size 0x%lx flags 0x%x\n",
	    Base, Size, flags);
#endif

    /* This requirers linux-0.99.pl10 or above */

    /*
     * Always do DENSE mmap, since read32/write32 currently require it.
     */
    ret = (unsigned long)mmap((caddr_t)(DENSE_BASE + Base), Size,
		   PROT_READ | PROT_WRITE,
		   MAP_SHARED, fd,
		   (off_t) (bus_base + Base));

    /*
     * Do SPARSE mmap only when MMIO and not MMIO_32BIT, or FRAMEBUFFER
     * and SPARSE (which should require the use of read/write macros).
     *
     * By not SPARSE mmapping an 8MB framebuffer, we can save approx. 256K
     * bytes worth of pagetable (32 pages).
     */
    if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) ||
	((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE)))
    {
        rets = (unsigned long)mmap((caddr_t)(SPARSE_BASE + (Base << 5)),
				   Size << 5, PROT_READ | PROT_WRITE,
				   MAP_SHARED, fd,
				   (off_t) _bus_base_sparse() + (Base << 5));
    }

    close(fd);
      
    if (ret == (unsigned long)MAP_FAILED) {
        FatalError("xf86MapVidMemSparse: Could not (dense) mmap fb (%s)\n",
		   strerror(errno));
    }

    if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) ||
	((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE)))
    {
        if (rets == (unsigned long)MAP_FAILED ||
	    rets != (SPARSE_BASE + (Base << 5)))
	{
	    FatalError("mapVidMemSparse: Could not (sparse) mmap fb (%s)\n",
		       strerror(errno));
	}
    }

#if 1
    if (rets)
        xf86Msg(X_INFO,"mapVidMemSparse: mapped Base 0x%lx size 0x%lx"
		" to DENSE at 0x%lx and SPARSE at 0x%lx\n",
		Base, Size, ret, rets);
    else
        xf86Msg(X_INFO,"mapVidMemSparse: mapped Base 0x%lx size 0x%lx"
		" to DENSE only at 0x%lx\n",
		Base, Size, ret);

#endif
    return (pointer) ret;
}

static void
unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size)
{
    unsigned long Offset = (unsigned long)Base - DENSE_BASE;
#if 1
    xf86Msg(X_INFO,"unmapVidMemSparse: unmapping Base 0x%lx Size 0x%lx\n",
	    Base, Size);
#endif
    /* Unmap DENSE always. */
    munmap((caddr_t)Base, Size);

    /* Unmap SPARSE always, and ignore error in case we did not map it. */
    munmap((caddr_t)(SPARSE_BASE + (Offset << 5)), Size << 5);
}

static int
readSparse8(pointer Base, register unsigned long Offset)
{
    register unsigned long result, shift;
    register unsigned long msb;

    mem_barrier();
    Offset += (unsigned long)Base - DENSE_BASE;
    shift = (Offset & 0x3) << 3;
    if (Offset >= (hae_thresh)) {
        msb = Offset & hae_mask;
        Offset -= msb;
	if (msb_set != msb) {
	    sethae(msb);
	    msb_set = msb;
	}
    }

    mem_barrier();
    result = *(vuip) (SPARSE_BASE + (Offset << 5));
    result >>= shift;
    return 0xffUL & result;
}

static int
readSparse16(pointer Base, register unsigned long Offset)
{
    register unsigned long result, shift;
    register unsigned long msb;

    mem_barrier();
    Offset += (unsigned long)Base - DENSE_BASE;
    shift = (Offset & 0x2) << 3;
    if (Offset >= hae_thresh) {
        msb = Offset & hae_mask;
        Offset -= msb;
	if (msb_set != msb) {
	    sethae(msb);
	    msb_set = msb;
	}
    }

    mem_barrier();
    result = *(vuip)(SPARSE_BASE + (Offset<<5) + (1<<(5-2)));
    result >>= shift;
    return 0xffffUL & result;
}

static int
readSparse32(pointer Base, register unsigned long Offset)
{
    /* NOTE: this is really using DENSE. */
    mem_barrier();
    return *(vuip)((unsigned long)Base+(Offset));
}

static void
writeSparse8(int Value, pointer Base, register unsigned long Offset)
{
    register unsigned long msb;
    register unsigned int b = Value & 0xffU;

    write_mem_barrier();
    Offset += (unsigned long)Base - DENSE_BASE;
    if (Offset >= hae_thresh) {
        msb = Offset & hae_mask;
	Offset -= msb;
	if (msb_set != msb) {
	    sethae(msb); 
	    msb_set = msb;
	}
    }

    write_mem_barrier();
    *(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101;
}

static void
writeSparse16(int Value, pointer Base, register unsigned long Offset)
{
    register unsigned long msb;
    register unsigned int w = Value & 0xffffU;

    write_mem_barrier();
    Offset += (unsigned long)Base - DENSE_BASE;
    if (Offset >= hae_thresh) {
        msb = Offset & hae_mask;
	Offset -= msb;
	if (msb_set != msb) {
	    sethae(msb);
	    msb_set = msb;
	}
    }

    write_mem_barrier();
    *(vuip)(SPARSE_BASE + (Offset<<5) + (1<<(5-2))) = w * 0x00010001;
}

static void
writeSparse32(int Value, pointer Base, register unsigned long Offset)
{
    /* NOTE: this is really using DENSE. */
    write_mem_barrier();
    *(vuip)((unsigned long)Base + (Offset)) = Value;
    return;
}

static void
writeSparseNB8(int Value, pointer Base, register unsigned long Offset)
{
    register unsigned long msb;
    register unsigned int b = Value & 0xffU;

    Offset += (unsigned long)Base - DENSE_BASE;
    if (Offset >= hae_thresh) {
        msb = Offset & hae_mask;
	Offset -= msb;
	if (msb_set != msb) {
	    sethae(msb);
	    msb_set = msb;
	}
    }
    *(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101;
}

static void
writeSparseNB16(int Value, pointer Base, register unsigned long Offset)
{
    register unsigned long msb;
    register unsigned int w = Value & 0xffffU;

    Offset += (unsigned long)Base - DENSE_BASE;
    if (Offset >= hae_thresh) {
        msb = Offset & hae_mask;
	Offset -= msb;
	if (msb_set != msb) {
	    sethae(msb);
	    msb_set = msb;
	}
    }
    *(vuip)(SPARSE_BASE+(Offset<<5)+(1<<(5-2))) = w * 0x00010001;
}

static void
writeSparseNB32(int Value, pointer Base, register unsigned long Offset)
{
    /* NOTE: this is really using DENSE. */
    *(vuip)((unsigned long)Base + (Offset)) = Value;
    return;
}

void (*xf86WriteMmio8)(int Value, pointer Base, unsigned long Offset) 
     = writeDense8;
void (*xf86WriteMmio16)(int Value, pointer Base, unsigned long Offset)
     = writeDense16;
void (*xf86WriteMmio32)(int Value, pointer Base, unsigned long Offset)
     = writeDense32;
void (*xf86WriteMmioNB8)(int Value, pointer Base, unsigned long Offset) 
     = writeDenseNB8;
void (*xf86WriteMmioNB16)(int Value, pointer Base, unsigned long Offset)
     = writeDenseNB16;
void (*xf86WriteMmioNB32)(int Value, pointer Base, unsigned long Offset)
     = writeDenseNB32;
int  (*xf86ReadMmio8)(pointer Base, unsigned long Offset) 
     = readDense8;
int  (*xf86ReadMmio16)(pointer Base, unsigned long Offset)
     = readDense16;
int  (*xf86ReadMmio32)(pointer Base, unsigned long Offset)
     = readDense32;

#ifdef JENSEN_SUPPORT

static int
readSparseJensen8(pointer Base, register unsigned long Offset);
static int
readSparseJensen16(pointer Base, register unsigned long Offset);
static int
readSparseJensen32(pointer Base, register unsigned long Offset);
static void
writeSparseJensen8(int Value, pointer Base, register unsigned long Offset);
static void
writeSparseJensen16(int Value, pointer Base, register unsigned long Offset);
static void
writeSparseJensen32(int Value, pointer Base, register unsigned long Offset);
static void
writeSparseJensenNB8(int Value, pointer Base, register unsigned long Offset);
static void
writeSparseJensenNB16(int Value, pointer Base, register unsigned long Offset);
static void
writeSparseJensenNB32(int Value, pointer Base, register unsigned long Offset);

/*
 * The Jensen lacks dense memory, thus we have to address the bus via
 * the sparse addressing scheme.
 *
 * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996
 */

#ifdef TEST_JENSEN_CODE 
#define SPARSE (5)
#else
#define SPARSE (7)
#endif

#define JENSEN_SHIFT(x) ((long)x<<SPARSE)

static pointer
mapVidMemJensen(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
  pointer base;
  int fd;

  xf86WriteMmio8 = writeSparseJensen8;
  xf86WriteMmio16 = writeSparseJensen16;
  xf86WriteMmio32 = writeSparseJensen32;
  xf86WriteMmioNB8 = writeSparseJensenNB8;
  xf86WriteMmioNB16 = writeSparseJensenNB16;
  xf86WriteMmioNB32 = writeSparseJensenNB32;
  xf86ReadMmio8 = readSparseJensen8;
  xf86ReadMmio16 = readSparseJensen16;
  xf86ReadMmio32 = readSparseJensen32;

  if ((fd = open(DEV_MEM, O_RDWR)) < 0) {
    FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
	       strerror(errno));
  }
  /* This requires linux-0.99.pl10 or above */
  base = mmap((caddr_t)0, JENSEN_SHIFT(Size),
	      PROT_READ|PROT_WRITE,
	      MAP_SHARED, fd,
	      (off_t)(JENSEN_SHIFT((off_t)Base) + _bus_base_sparse()));
  close(fd);
  if (base == MAP_FAILED) {
    FatalError("xf86MapVidMem: Could not mmap framebuffer"
	       " (0x%08x,0x%x) (%s)\n", Base, Size,
	       strerror(errno));
  }
  return base;
}

static void
unmapVidMemJensen(int ScreenNum, pointer Base, unsigned long Size)
{
  munmap((caddr_t)Base, JENSEN_SHIFT(Size));
}

static int
readSparseJensen8(pointer Base, register unsigned long Offset)
{
    register unsigned long result, shift;

    mem_barrier();
    shift = (Offset & 0x3) << 3;

    result = *(vuip) ((unsigned long)Base + (Offset << SPARSE));

    result >>= shift;
    return 0xffUL & result;
}

static int
readSparseJensen16(pointer Base, register unsigned long Offset)
{
    register unsigned long result, shift;

    mem_barrier();
    shift = (Offset & 0x2) << 3;

    result = *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(1<<(SPARSE-2)));

    result >>= shift;
    return 0xffffUL & result;
}

static int
readSparseJensen32(pointer Base, register unsigned long Offset)
{
    register unsigned long result;

    mem_barrier();
    result = *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(3<<(SPARSE-2)));

    return result;
}

static void
writeSparseJensen8(int Value, pointer Base, register unsigned long Offset)
{
    register unsigned int b = Value & 0xffU;

    write_mem_barrier();
    *(vuip) ((unsigned long)Base + (Offset << SPARSE)) = b * 0x01010101;
}

static void
writeSparseJensen16(int Value, pointer Base, register unsigned long Offset)
{
    register unsigned int w = Value & 0xffffU;

    write_mem_barrier();
    *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(1<<(SPARSE-2))) =
      w * 0x00010001;
}

static void
writeSparseJensen32(int Value, pointer Base, register unsigned long Offset)
{
    write_mem_barrier();
    *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(3<<(SPARSE-2))) = Value;
}

static void
writeSparseJensenNB8(int Value, pointer Base, register unsigned long Offset)
{
    register unsigned int b = Value & 0xffU;

    *(vuip) ((unsigned long)Base + (Offset << SPARSE)) = b * 0x01010101;
}

static void
writeSparseJensenNB16(int Value, pointer Base, register unsigned long Offset)
{
    register unsigned int w = Value & 0xffffU;

    *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(1<<(SPARSE-2))) =
      w * 0x00010001;
}

static void
writeSparseJensenNB32(int Value, pointer Base, register unsigned long Offset)
{
    *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(3<<(SPARSE-2))) = Value;
}
#endif /* JENSEN_SUPPORT */

#endif /* __alpha__ */

Reply to: