Minix Support

This commit is contained in:
Lionel Sambuc 2014-01-10 21:17:13 +01:00
parent 055d5fa67c
commit a95b153bbc
55 changed files with 1267 additions and 22 deletions

View File

@ -117,11 +117,13 @@
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
/* #undef HAVE_NDIR_H */
#if !defined(__minix)
/* Define to 1 if you have the 'posix_fadvise' function. */
#define HAVE_POSIX_FADVISE 1
/* Have POSIX threads */
#define HAVE_PTHREAD 1
#endif /* !defined(__minix) */
/* Have PTHREAD_PRIO_INHERIT. */
/* #undef HAVE_PTHREAD_PRIO_INHERIT */

View File

@ -40,8 +40,10 @@
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
#if !defined(__minix)
/* Support IPv6 for TCP connections */
#define IPv6 1
#endif /* !defined(__minix) */
/* Support os-specific local connections */
/* #undef LOCALCONN */

View File

@ -97,7 +97,12 @@ typedef pthread_t xthread_t;
#pragma weak tis_cond_signal = _Xthr_zero_stub_
#pragma weak tis_cond_broadcast = _Xthr_zero_stub_
#else
# if defined(__minix)
#define _MTHREADIFY_PTHREADS 1
#include <minix/mthread.h>
# else
#include <pthread.h>
# endif /* defined(__minix) */
typedef pthread_t xthread_t;
#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
xthread_t pthread_self() __attribute__ ((weak, alias ("_Xthr_self_stub_")));

View File

@ -52,8 +52,10 @@
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
#if !defined(__minix)
/* Support IPv6 for TCP connections */
#define IPv6 1
#endif /* !defined(__minix) */
/* Support os-specific local connections */
/* #undef LOCALCONN */

View File

@ -551,6 +551,7 @@ MapPhysAddress(unsigned long address, unsigned long size)
vaddr = (void *)smem_create("XF86DGA", (char *)offset,
size + delta, SM_READ|SM_WRITE);
#else
#if !defined(__minix)
#ifndef MAP_FILE
#define MAP_FILE 0
#endif
@ -562,6 +563,7 @@ MapPhysAddress(unsigned long address, unsigned long size)
MAP_FILE | MAP_SHARED, mapFd, (off_t)offset);
if (vaddr == (void *)-1)
return NULL;
#endif /* !defined(__minix) */
#endif
if (!vaddr) {
@ -624,14 +626,14 @@ XF86DGADirectVideo(
if (enable & XF86DGADirectGraphics) {
#if !defined(ISC) && !defined(HAS_SVR3_MMAP) \
&& !(defined(Lynx) && defined(NO_MMAP)) \
&& !defined(__UNIXOS2__)
&& !defined(__UNIXOS2__) && !defined(__minix)
if (mp && mp->vaddr)
mprotect(mp->vaddr, mp->size + mp->delta, PROT_READ | PROT_WRITE);
#endif
} else {
#if !defined(ISC) && !defined(HAS_SVR3_MMAP) \
&& !(defined(Lynx) && defined(NO_MMAP)) \
&& !defined(__UNIXOS2__)
&& !defined(__UNIXOS2__) && !defined(__minix)
if (mp && mp->vaddr)
mprotect(mp->vaddr, mp->size + mp->delta, PROT_READ);
#elif defined(Lynx) && defined(NO_MMAP)

View File

@ -967,6 +967,7 @@ DGAMapPhysical(
#ifndef MAP_FILE
#define MAP_FILE 0
#endif
#if !defined(__minix)
if (!name)
name = DEV_MEM;
if ((pMap->fd = open(name, O_RDWR)) < 0)
@ -976,6 +977,7 @@ DGAMapPhysical(
if (pMap->virtual == (void *)-1)
return False;
mprotect(pMap->virtual, size, PROT_READ | PROT_WRITE);
#endif /* !defined(__minix) */
#endif
return True;
@ -996,7 +998,9 @@ DGAUnmapPhysical(DGAMapPtr pMap)
smem_remove("XF86DGA");
#else
if (pMap->virtual && pMap->virtual != (void *)-1) {
#if !defined(__minix)
mprotect(pMap->virtual,pMap->size, PROT_READ);
#endif /* ! defined(__minix) */
munmap(pMap->virtual, pMap->size);
pMap->virtual = 0;
}

View File

@ -43,7 +43,12 @@
#include <assert.h>
#include <errno.h>
#include <xf86drm.h>
#if !defined(__minix)
#include <pthread.h>
#else
#define _MTHREADIFY_PTHREADS 1
#include <minix/mthread.h>
#endif /* !defined(__minix) */
#include "intel_bufmgr.h"
#include "intel_bufmgr_priv.h"
#include "drm.h"

View File

@ -46,7 +46,12 @@
#include <string.h>
#include <unistd.h>
#include <assert.h>
#if !defined(__minix)
#include <pthread.h>
#else
#define _MTHREADIFY_PTHREADS 1
#include <minix/mthread.h>
#endif /* !defined(__minix) */
#include <stddef.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
@ -1062,9 +1067,13 @@ int drm_intel_gem_bo_map_gtt(drm_intel_bo *bo)
}
/* and mmap it */
#if !defined(__minix)
bo_gem->gtt_virtual = mmap(0, bo->size, PROT_READ | PROT_WRITE,
MAP_SHARED, bufmgr_gem->fd,
mmap_arg.offset);
#else
bo_gem->gtt_virtual = MAP_FAILED;
#endif /* !defined(__minix) */
if (bo_gem->gtt_virtual == MAP_FAILED) {
bo_gem->gtt_virtual = NULL;
ret = -errno;

View File

@ -178,7 +178,11 @@ static int bo_map(struct radeon_bo_int *boi, int write)
boi, boi->handle, r);
return r;
}
#if !defined(__minix)
ptr = mmap(0, args.size, PROT_READ|PROT_WRITE, MAP_SHARED, boi->bom->fd, args.addr_ptr);
#else
ptr = MAP_FAILED;
#endif /* !defined(__minix) */
if (ptr == MAP_FAILED)
return -errno;
bo_gem->priv_ptr = ptr;

View File

@ -33,7 +33,12 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#if !defined(__minix)
#include <pthread.h>
#else
#define _MTHREADIFY_PTHREADS 1
#include <minix/mthread.h>
#endif /* !defined(__minix) */
#include <sys/mman.h>
#include <sys/ioctl.h>
#include "radeon_cs.h"

View File

@ -92,7 +92,7 @@ typedef struct { uint_t atomic; } atomic_t;
#endif
#if defined(__NetBSD__) && !defined(HAS_ATOMIC_OPS) /* NetBSD */
#if (defined(__NetBSD__) || defined(__minix)) && !defined(HAS_ATOMIC_OPS) /* NetBSD */
#include <sys/atomic.h>
#define HAS_ATOMIC_OPS 1

View File

@ -1128,7 +1128,11 @@ int drmMap(int fd, drm_handle_t handle, drmSize size, drmAddressPtr address)
size = (size + pagesize_mask) & ~pagesize_mask;
#if !defined(__minix)
*address = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, handle);
#else
*address = MAP_FAILED;
#endif /* !defined(__minix) */
if (*address == MAP_FAILED)
return -errno;
return 0;

View File

@ -56,6 +56,8 @@ pci_system_init( void )
err = pci_system_linux_sysfs_create();
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
err = pci_system_freebsd_create();
#elif defined(__minix)
err = pci_system_minix_create();
#elif defined(__NetBSD__)
err = pci_system_netbsd_create();
#elif defined(__OpenBSD__)

View File

@ -74,7 +74,7 @@
#define HTOLE_16(x) htole16(x)
#define HTOLE_32(x) htole32(x)
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__minix)
#define LETOH_16(x) le16toh(x)
#define LETOH_32(x) le32toh(x)
#else

View File

@ -0,0 +1,689 @@
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/ttycom.h>
#include <sys/video.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <dev/pci/pcidevs.h>
#include <dev/pci/pciio.h>
#include <dev/pci/pcireg.h>
#include <pci.h>
#include "pciaccess.h"
#include "pciaccess_private.h"
static int nbuses = 1;
static struct {
int pci_fd;
} _state;
static int
pci_read(int domain, int bus, int dev, int func, uint32_t reg, uint32_t *val)
{
uint32_t rval;
if ((domain < 0) || (domain > nbuses))
return -1;
#if 0
if (pcibus_conf_read(buses[domain].fd, (unsigned int)bus,
#else
if (pcibus_conf_read(_state.pci_fd, (unsigned int)bus,
#endif
(unsigned int)dev, (unsigned int)func, reg, &rval) == -1)
return (-1);
*val = rval;
return 0;
}
static int
pci_write(int domain, int bus, int dev, int func, uint32_t reg, uint32_t val)
{
if ((domain < 0) || (domain > nbuses))
return -1;
#if 0
return pcibus_conf_write(buses[domain].fd, (unsigned int)bus,
#else
return pcibus_conf_write(_state.pci_fd, (unsigned int)bus,
#endif
(unsigned int)dev, (unsigned int)func, reg, val);
}
static int
pci_nfuncs(int domain, int bus, int dev)
{
uint32_t hdr;
if ((domain < 0) || (domain > nbuses))
return -1;
if (pci_read(domain, bus, dev, 0, PCI_BHLC_REG, &hdr) != 0)
return -1;
return (PCI_HDRTYPE_MULTIFN(hdr) ? 8 : 1);
}
/*ARGSUSED*/
static int
pci_device_minix_map_range(struct pci_device *dev,
struct pci_device_mapping *map)
{
#ifdef HAVE_MTRR
struct mtrr m;
int n = 1;
#endif
int prot, ret = 0;
prot = PROT_READ;
if (map->flags & PCI_DEV_MAP_FLAG_WRITABLE)
prot |= PROT_WRITE;
#if 0
map->memory = mmap(NULL, (size_t)map->size, prot, MAP_SHARED,
buses[dev->domain].fd, (off_t)map->base);
#else
{
struct pciio_map _map;
int r;
_map.flags = 0;
_map.phys_offset = map->base;
_map.size = map->size;
_map.readonly = (map->flags & PCI_DEV_MAP_FLAG_WRITABLE) != PCI_DEV_MAP_FLAG_WRITABLE;
r = ioctl(_state.pci_fd, PCI_IOC_MAP, &_map);
map->memory = _map.vaddr_ret;
if (r < 0) {
map->memory = MAP_FAILED;
}
}
#endif
if (map->memory == MAP_FAILED)
return errno;
#ifdef HAVE_MTRR
memset(&m, 0, sizeof(m));
/* No need to set an MTRR if it's the default mode. */
if ((map->flags & PCI_DEV_MAP_FLAG_CACHABLE) ||
(map->flags & PCI_DEV_MAP_FLAG_WRITE_COMBINE)) {
m.base = map->base;
m.flags = MTRR_VALID | MTRR_PRIVATE;
m.len = map->size;
m.owner = getpid();
if (map->flags & PCI_DEV_MAP_FLAG_CACHABLE)
m.type = MTRR_TYPE_WB;
if (map->flags & PCI_DEV_MAP_FLAG_WRITE_COMBINE)
m.type = MTRR_TYPE_WC;
if ((netbsd_set_mtrr(&m, &n)) == -1) {
fprintf(stderr, "mtrr set failed: %s\n",
strerror(errno));
}
}
#endif
return ret;
}
static int
pci_device_minix_unmap_range(struct pci_device *dev,
struct pci_device_mapping *map)
{
#ifdef HAVE_MTRR
struct mtrr m;
int n = 1;
memset(&m, 0, sizeof(m));
if ((map->flags & PCI_DEV_MAP_FLAG_CACHABLE) ||
(map->flags & PCI_DEV_MAP_FLAG_WRITE_COMBINE)) {
m.base = map->base;
m.flags = 0;
m.len = map->size;
m.type = MTRR_TYPE_UC;
(void)netbsd_set_mtrr(&m, &n);
}
#endif
#if 0
return pci_device_generic_unmap_range(dev, map);
#else
{
struct pciio_map _map;
_map.size = map->size;
_map.vaddr = map->memory;
return ioctl(_state.pci_fd, PCI_IOC_UNMAP, &_map);
}
#endif
}
static int
pci_device_minix_read(struct pci_device *dev, void *data,
pciaddr_t offset, pciaddr_t size, pciaddr_t *bytes_read)
{
u_int reg, rval;
*bytes_read = 0;
while (size > 0) {
size_t toread = MIN(size, 4 - (offset & 0x3));
reg = (u_int)(offset & ~0x3);
#if 0
if ((pcibus_conf_read(buses[dev->domain].fd,
#else
if ((pcibus_conf_read(_state.pci_fd,
#endif
(unsigned int)dev->bus, (unsigned int)dev->dev,
(unsigned int)dev->func, reg, &rval)) == -1)
return errno;
rval = htole32(rval);
rval >>= ((offset & 0x3) * 8);
memcpy(data, &rval, toread);
offset += toread;
data = (char *)data + toread;
size -= toread;
*bytes_read += toread;
}
return 0;
}
static int
pci_device_minix_write(struct pci_device *dev, const void *data,
pciaddr_t offset, pciaddr_t size, pciaddr_t *bytes_written)
{
u_int reg, val;
if ((offset % 4) != 0 || (size % 4) != 0)
return EINVAL;
*bytes_written = 0;
while (size > 0) {
reg = (u_int)offset;
memcpy(&val, data, 4);
#if 0
if ((pcibus_conf_write(buses[dev->domain].fd,
#else
if ((pcibus_conf_write(_state.pci_fd,
#endif
(unsigned int)dev->bus, (unsigned int)dev->dev,
(unsigned int)dev->func, reg, val)) == -1)
return errno;
offset += 4;
data = (const char *)data + 4;
size -= 4;
*bytes_written += 4;
}
return 0;
}
static int
pci_device_minix_boot_vga(struct pci_device *dev)
{
/*FIXME: This should check this is the vga device used by the console*/
return 0;
}
static int
pci_device_minix_map_legacy(struct pci_device *dev, pciaddr_t base,
pciaddr_t size, unsigned map_flags, void **addr)
{
struct pci_device_mapping map;
int err;
map.base = base;
map.size = size;
map.flags = map_flags;
map.memory = NULL;
err = pci_device_minix_map_range(dev, &map);
*addr = map.memory;
return err;
}
static int
pci_device_minix_unmap_legacy(struct pci_device *dev, void *addr, pciaddr_t size)
{
struct pci_device_mapping map;
map.memory = addr;
map.size = size;
map.flags = 0;
return pci_device_minix_unmap_range(dev, &map);
}
static void
pci_system_minix_destroy(void)
{
free(pci_sys->devices);
free(pci_sys);
close(_state.pci_fd);
}
static void
pci_system_minix_destroy_device( struct pci_device *dev)
{
int r;
struct pciio_acl acl;
acl.domain = dev->domain;
acl.bus = dev->bus;
acl.device = dev->dev;
acl.function = dev->func;
r = ioctl(_state.pci_fd, PCI_IOC_RELEASE, &acl);
if (r < 0)
fprintf(stderr, "%s:%d PCI release failed r = %d\n", __func__, __LINE__, r);
}
static int
pci_device_minix_probe(struct pci_device *device)
{
struct pci_device_private *priv =
(struct pci_device_private *)(void *)device;
struct pci_mem_region *region;
uint64_t reg64, size64;
uint32_t bar, reg, size;
int bus, dev, func, err, domain;
domain = device->domain;
bus = device->bus;
dev = device->dev;
func = device->func;
/* Enable the device if necessary */
err = pci_read(domain, bus, dev, func, PCI_COMMAND_STATUS_REG, &reg);
if (err)
return err;
if ((reg & (PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE | PCI_COMMAND_MASTER_ENABLE)) !=
(PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE | PCI_COMMAND_MASTER_ENABLE)) {
reg |= PCI_COMMAND_IO_ENABLE |
PCI_COMMAND_MEM_ENABLE |
PCI_COMMAND_MASTER_ENABLE;
err = pci_write(domain, bus, dev, func, PCI_COMMAND_STATUS_REG,
reg);
if (err)
return err;
}
err = pci_read(domain, bus, dev, func, PCI_BHLC_REG, &reg);
if (err)
return err;
priv->header_type = PCI_HDRTYPE_TYPE(reg);
if (priv->header_type != 0)
return 0;
#if 1
{
struct pciio_acl acl;
acl.domain = domain;
acl.bus = bus;
acl.device = dev;
acl.function = func;
err = ioctl(_state.pci_fd, PCI_IOC_RESERVE, &acl);
if (err < 0)
return err;
}
#endif
region = device->regions;
for (bar = PCI_MAPREG_START; bar < PCI_MAPREG_END;
bar += sizeof(uint32_t), region++) {
err = pci_read(domain, bus, dev, func, bar, &reg);
if (err)
return err;
/* Probe the size of the region. */
err = pci_write(domain, bus, dev, func, bar, (unsigned int)~0);
if (err)
return err;
pci_read(domain, bus, dev, func, bar, &size);
pci_write(domain, bus, dev, func, bar, reg);
if (PCI_MAPREG_TYPE(reg) == PCI_MAPREG_TYPE_IO) {
region->is_IO = 1;
region->base_addr = PCI_MAPREG_IO_ADDR(reg);
region->size = PCI_MAPREG_IO_SIZE(size);
} else {
if (PCI_MAPREG_MEM_PREFETCHABLE(reg))
region->is_prefetchable = 1;
switch(PCI_MAPREG_MEM_TYPE(reg)) {
case PCI_MAPREG_MEM_TYPE_32BIT:
case PCI_MAPREG_MEM_TYPE_32BIT_1M:
region->base_addr = PCI_MAPREG_MEM_ADDR(reg);
region->size = PCI_MAPREG_MEM_SIZE(size);
break;
case PCI_MAPREG_MEM_TYPE_64BIT:
region->is_64 = 1;
reg64 = reg;
size64 = size;
bar += sizeof(uint32_t);
err = pci_read(domain, bus, dev, func, bar, &reg);
if (err)
return err;
reg64 |= (uint64_t)reg << 32;
err = pci_write(domain, bus, dev, func, bar,
(unsigned int)~0);
if (err)
return err;
pci_read(domain, bus, dev, func, bar, &size);
pci_write(domain, bus, dev, func, bar,
(unsigned int)(reg64 >> 32));
size64 |= (uint64_t)size << 32;
region->base_addr =
(unsigned long)PCI_MAPREG_MEM64_ADDR(reg64);
region->size =
(unsigned long)PCI_MAPREG_MEM64_SIZE(size64);
region++;
break;
}
}
}
/* Probe expansion ROM if present */
err = pci_read(domain, bus, dev, func, PCI_MAPREG_ROM, &reg);
if (err)
return err;
if (reg != 0) {
err = pci_write(domain, bus, dev, func, PCI_MAPREG_ROM,
(uint32_t)(~PCI_MAPREG_ROM_ENABLE));
if (err)
return err;
pci_read(domain, bus, dev, func, PCI_MAPREG_ROM, &size);
pci_write(domain, bus, dev, func, PCI_MAPREG_ROM, reg);
if ((reg & PCI_MAPREG_MEM_ADDR_MASK) != 0) {
priv->rom_base = reg & PCI_MAPREG_MEM_ADDR_MASK;
device->rom_size = -(size & PCI_MAPREG_MEM_ADDR_MASK);
}
}
return 0;
}
static int
pci_device_minix_read_rom(struct pci_device *dev, void *buffer)
{
struct pci_device_private *priv = (struct pci_device_private *)(void *)dev;
void *bios;
pciaddr_t rom_base;
size_t rom_size;
uint32_t bios_val, command_val;
int pci_rom;
if (((priv->base.device_class >> 16) & 0xff) != PCI_CLASS_DISPLAY ||
((priv->base.device_class >> 8) & 0xff) != PCI_SUBCLASS_DISPLAY_VGA)
return ENOSYS;
if (priv->rom_base == 0) {
#if defined(__amd64__) || defined(__i386__)
/*
* We need a way to detect when this isn't the console and reject
* this request outright.
*/
rom_base = 0xc0000;
rom_size = 0x10000;
pci_rom = 0;
#else
return ENOSYS;
#endif
} else {
rom_base = priv->rom_base;
rom_size = dev->rom_size;
pci_rom = 1;
#if 0
if ((pcibus_conf_read(buses[dev->domain].fd, (unsigned int)dev->bus,
#else
if ((pcibus_conf_read(_state.pci_fd, (unsigned int)dev->bus,
#endif
(unsigned int)dev->dev, (unsigned int)dev->func,
PCI_COMMAND_STATUS_REG, &command_val)) == -1)
return errno;
if ((command_val & PCI_COMMAND_MEM_ENABLE) == 0) {
#if 0
if ((pcibus_conf_write(buses[dev->domain].fd,
#else
if ((pcibus_conf_write(_state.pci_fd,
#endif
(unsigned int)dev->bus, (unsigned int)dev->dev,
(unsigned int)dev->func, PCI_COMMAND_STATUS_REG,
command_val | PCI_COMMAND_MEM_ENABLE)) == -1)
return errno;
}
#if 0
if ((pcibus_conf_read(buses[dev->domain].fd, (unsigned int)dev->bus,
#else
if ((pcibus_conf_read(_state.pci_fd, (unsigned int)dev->bus,
#endif
(unsigned int)dev->dev, (unsigned int)dev->func,
PCI_MAPREG_ROM, &bios_val)) == -1)
return errno;
if ((bios_val & PCI_MAPREG_ROM_ENABLE) == 0) {
#if 0
if ((pcibus_conf_write(buses[dev->domain].fd,
#else
if ((pcibus_conf_write(_state.pci_fd,
#endif
(unsigned int)dev->bus,
(unsigned int)dev->dev, (unsigned int)dev->func,
PCI_MAPREG_ROM, bios_val | PCI_MAPREG_ROM_ENABLE)) == -1)
return errno;
}
}
fprintf(stderr, "Using rom_base = 0x%lx 0x%lx (pci_rom=%d)\n",
(long)rom_base, (long)rom_size, pci_rom);
#if 0
bios = mmap(NULL, rom_size, PROT_READ, MAP_SHARED, buses[dev->domain].fd,
(off_t)rom_base);
if (bios == MAP_FAILED) {
int serrno = errno;
return serrno;
}
#else
{
struct pciio_map map;
int r;
map.flags = 0;
map.phys_offset = rom_base;
map.size = rom_size;
map.readonly = 1;
r = ioctl(_state.pci_fd, PCI_IOC_MAP, &map);
if (r < 0) {
int serrno = errno;
return serrno;
}
bios = map.vaddr_ret;
}
#endif
memcpy(buffer, bios, rom_size);
#if 0
munmap(bios, rom_size);
#else
{
struct pciio_map map;
int r;
map.size = rom_size;
map.vaddr = bios;
r = ioctl(_state.pci_fd, PCI_IOC_UNMAP, &map);
if (r < 0) {
int serrno = errno;
return serrno;
}
}
#endif
if (pci_rom) {
if ((command_val & PCI_COMMAND_MEM_ENABLE) == 0) {
#if 0
if ((pcibus_conf_write(buses[dev->domain].fd,
#else
if ((pcibus_conf_write(_state.pci_fd,
#endif
(unsigned int)dev->bus,
(unsigned int)dev->dev, (unsigned int)dev->func,
PCI_COMMAND_STATUS_REG, command_val)) == -1)
return errno;
}
if ((bios_val & PCI_MAPREG_ROM_ENABLE) == 0) {
#if 0
if ((pcibus_conf_write(buses[dev->domain].fd,
#else
if ((pcibus_conf_write(_state.pci_fd,
#endif
(unsigned int)dev->bus,
(unsigned int)dev->dev, (unsigned int)dev->func,
PCI_MAPREG_ROM, bios_val)) == -1)
return errno;
}
}
return 0;
}
static const struct pci_system_methods minix_pci_methods = {
.destroy = pci_system_minix_destroy,
.destroy_device = pci_system_minix_destroy_device,
.read_rom = pci_device_minix_read_rom,
.probe = pci_device_minix_probe,
.map_range = pci_device_minix_map_range,
.unmap_range = pci_device_minix_unmap_range,
.read = pci_device_minix_read,
.write = pci_device_minix_write,
.fill_capabilities = pci_fill_capabilities_generic,
.boot_vga = pci_device_minix_boot_vga,
.map_legacy = pci_device_minix_map_legacy,
.unmap_legacy = pci_device_minix_unmap_legacy,
};
int
pci_system_minix_create(void)
{
#define READ_BUFF_SIZE 4096
#define DEV_PCI "/dev/pci"
#define PROC_PCI "/proc/pci"
FILE *file;
struct pci_device_private *device;
int ndevs;
char buf[READ_BUFF_SIZE];
/* Allocate top-level pci descriptor. */
pci_sys = calloc(1, sizeof(struct pci_system));
if (NULL == pci_sys) {
return ENOMEM;
}
pci_sys->methods = &minix_pci_methods;
file = fopen(PROC_PCI, "r");
if (NULL == file) {
return errno;
}
/* Allocate descriptors, one per pci device, so first figure how many
* there are to begin with. */
ndevs = 0;
while(NULL != fgets(buf, READ_BUFF_SIZE, file)) {
ndevs++;
}
device = calloc(ndevs, sizeof(struct pci_device_private));
if (device == NULL) {
perror("PCI devices private structures failed");
fclose(file);
return ENOMEM;
}
pci_sys->devices = device;
pci_sys->num_devices = ndevs;
/* Go back to the start of the file, this time parse each line and
* store the pci information in the allocated device arrray. */
if ( 0 != fseek(file, 0, SEEK_SET)) {
fclose(file);
return errno;
}
{
// slot bcr/scr/pifr/rev vid:did:subvid:subdid dev_name
// 0.0.30.0 6/4/1/a2 8086:244E:0000:0000 Intel 82801 PCI Bridge
int domain, bus, dev, func;
int bcr, scr, pifr, rev;
int vid, did, svid, sdid;
char dev_name[100];
while(0 < fscanf(file, "%d.%d.%d.%d %x/%x/%x/%x %04X:%04X:%04X:%04X",
&domain, &bus, &dev, &func,
&bcr, &scr, &pifr, &rev,
&vid, &did, &svid, &sdid
)) {
char *p = fgets(dev_name, 100, file);
#if 0
fprintf(stderr, "%d.%d.%d.%d %x/%x/%x/%x %04X:%04X:%04X:%04X %s\n",
domain, bus, dev, func,
bcr, scr, pifr, rev,
vid, did, dev_name
);
#endif
device->base.domain = domain;
device->base.bus = bus;
device->base.dev = dev;
device->base.func = func;
device->base.vendor_id = vid;
device->base.device_id = did;
device->base.subvendor_id = svid;
device->base.subdevice_id = sdid;
device->base.device_class = bcr << 16 | scr << 8 | pifr;
device->base.revision = rev;
device++;
}
fclose(file);
}
_state.pci_fd = open(DEV_PCI, O_RDONLY);
if (_state.pci_fd < 0) {
return errno;
}
return 0;
}

View File

@ -181,6 +181,7 @@ extern struct pci_system * pci_sys;
extern int pci_system_linux_sysfs_create( void );
extern int pci_system_freebsd_create( void );
extern int pci_system_minix_create( void );
extern int pci_system_netbsd_create( void );
extern int pci_system_openbsd_create( void );
extern void pci_system_openbsd_init_dev_mem( int );

View File

@ -35,12 +35,19 @@
#include <stdint.h>
#endif
#if defined(__minix)
#define _MTHREADIFY_PTHREADS 1
#include <minix/mthread.h>
#endif /* defined(__minix) */
#ifndef _WIN32
#include <sys/uio.h>
#else
#include "xcb_windefs.h"
#endif
#if !defined(__minix)
#include <pthread.h>
#endif /* !defined(__minix) */
#ifdef __cplusplus

View File

@ -29,6 +29,9 @@
#include "config.h"
#endif
#if defined(__minix)
#include <time.h>
#endif /* defined(__minix) */
#include <assert.h>
#include <X11/Xauth.h>
#include <sys/param.h>

View File

@ -86,8 +86,10 @@
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
#if !defined(__minix)
/* poll() function is available */
#define USE_POLL 1
#endif /* !defined(__minix) */
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE

View File

@ -1,8 +1,10 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
#if !defined(__minix)
/* Define to 1 if you have the `grantpt' function. */
#define HAVE_GRANTPT 1
#endif /* !defined(__minix) */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

View File

@ -31,11 +31,13 @@
/* Whether we have mmap() */
#define HAVE_MMAP 1
#if !defined(__minix)
/* Whether we have mprotect() */
#define HAVE_MPROTECT 1
/* Whether we have posix_memalign() */
#define HAVE_POSIX_MEMALIGN 1
#endif /* !defined(__minix) */
/* Whether pthread_setspecific() is supported */
/* #undef HAVE_PTHREAD_SETSPECIFIC */

View File

@ -39,7 +39,12 @@
#define __XCB_REPLY_H__
#include <xcb/xcb.h>
#if !defined(__minix)
#include <pthread.h>
#else
#define _MTHREADIFY_PTHREADS 1
#include <minix/mthread.h>
#endif /* !defined(__minix) */
#ifdef __cplusplus
extern "C" {

View File

@ -207,7 +207,7 @@ TransMapRec sysconsCODE = {
#endif
#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
#ifdef WSCONS_SUPPORT
#if defined(WSCONS_SUPPORT) || defined(__minix)
static CARD8 wsUsbMap[] = {
/* 0 */ KEY_NOTUSED,
@ -1229,7 +1229,7 @@ TransMapRec wsSun = {
wsSunMap
};
#endif /* WSCONS_SUPPORT */
#endif /* WSCONS_SUPPORT || __minix */
/*ARGSUSED*/
@ -1352,6 +1352,11 @@ KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
pKbd->RemapScanCode = ATScancode;
break;
#endif
#if defined(__minix)
case MXCONS:
pKbd->scancodeMap = &wsUsb;
break;
#endif /* defined(__minix) */
#ifdef WSCONS_SUPPORT
case WSCONS:
if (!pKbd->isConsole) {

View File

@ -27,8 +27,22 @@
#include "atKeynames.h"
#include "bsd_kbd.h"
#if defined(__minix)
#include <minix/input.h>
#include <sys/kbdio.h>
#include <sys/ttycom.h>
#define LED_NUM KBD_LEDS_NUM
#define LED_CAP KBD_LEDS_CAPS
#define LED_SCR KBD_LEDS_CAPS
#endif /* defined(__minix) */
static KbdProtocolRec protocols[] = {
{"standard", PROT_STD },
#if defined(__minix)
{"mxkbd", PROT_MXCONS },
#endif /* defined(__minix) */
#ifdef WSCONS_SUPPORT
{"wskbd", PROT_WSCONS },
#endif
@ -56,6 +70,9 @@ int KbdInit(InputInfoPtr pInfo, int what)
#endif
tcgetattr(pInfo->fd, &(priv->kbdtty));
#endif
#if defined(__minix)
case MXCONS:
#endif /* defined(__minix) */
break;
}
}
@ -92,6 +109,15 @@ SetKbdLeds(InputInfoPtr pInfo, int leds)
ioctl(pInfo->fd, KDSETLED, real_leds);
break;
#endif
#if defined(__minix)
case MXCONS:
{
struct kio_leds _leds;
_leds.kl_bits = real_leds;
ioctl(pInfo->fd, KIOCSLEDS, &_leds);
}
break;
#endif /* defined(__minix) */
#if defined(WSCONS_SUPPORT)
case WSCONS:
ioctl(pInfo->fd, WSKBDIO_SETLEDS, &real_leds);
@ -206,6 +232,14 @@ KbdOn(InputInfoPtr pInfo, int what)
#endif
} else {
switch (pKbd->consType) {
#if defined(__minix)
case MXCONS:
if (pInfo->fd == -1) {
xf86Msg(X_INFO, "opening %s\n", "/dev/kbdmux");
pInfo->fd = open("/dev/kbdmux", O_RDONLY | O_NONBLOCK);
}
break;
#endif /* defined(__minix) */
#ifdef WSCONS_SUPPORT
case WSCONS:
if ((pKbd->wsKbdDev[0] != 0) && (pInfo->fd == -1)) {
@ -258,6 +292,16 @@ KbdOff(InputInfoPtr pInfo, int what)
}
} else {
switch (pKbd->consType) {
#if defined(__minix)
case MXCONS:
if (pInfo->fd != -1) {
xf86Msg(X_INFO, "closing %s\n", "/dev/kbdmux");
/* need to close the fd while we're gone */
close(pInfo->fd);
pInfo->fd = -1;
}
break;
#endif /* defined(__minix) */
#ifdef WSCONS_SUPPORT
case WSCONS:
if ((pKbd->wsKbdDev[0] != 0) && (pInfo->fd != -1)) {
@ -358,6 +402,39 @@ printWsType(const char *type, char *name)
}
#endif
#if defined(__minix)
#define NUMEVENTS 64
static void
MxReadInput(InputInfoPtr pInfo)
{
KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
static struct input_event eventList[NUMEVENTS];
struct input_event *event = eventList;
int n;
n = read(pInfo->fd, (char *)event, sizeof(eventList));
if (n == 0)
return;
n /= sizeof(struct input_event);
while( n-- ) {
switch(event->page) {
case INPUT_PAGE_KEY:
pKbd->PostEvent(pInfo, event->code, event->value == INPUT_RELEASE ? FALSE : TRUE);
break;
default:
LogMessageVerbSigSafe(X_WARNING, -1,
"%s: bad MinixCons event: page %04x code %04x value %08x flags %04x devid %04x\n",
pInfo->name, event->page, event->code, event->value, event->flags, event->devid);
}
++event;
}
}
#endif /* defined(__minix) */
static Bool
OpenKeyboard(InputInfoPtr pInfo)
{
@ -378,6 +455,11 @@ OpenKeyboard(InputInfoPtr pInfo)
case PROT_STD:
pInfo->read_input = stdReadInput;
break;
#ifdef __minix
case PROT_MXCONS:
pInfo->read_input = MxReadInput;
break;
#endif
#ifdef WSCONS_SUPPORT
case PROT_WSCONS:
pInfo->read_input = WSReadInput;
@ -392,6 +474,10 @@ OpenKeyboard(InputInfoPtr pInfo)
if (prot == PROT_WSCONS) {
s = xf86SetStrOption(pInfo->options, "Device", "/dev/wskbd");
#if defined(__minix)
} else if (prot == PROT_MXCONS) {
s = xf86SetStrOption(pInfo->options, "Device", "/dev/kbdmux");
#endif /* defined(__minix) */
} else
s = xf86SetStrOption(pInfo->options, "Device", NULL);
@ -413,6 +499,11 @@ OpenKeyboard(InputInfoPtr pInfo)
free(s);
}
#if defined(__minix)
if( prot == PROT_MXCONS) {
pKbd->consType = MXCONS;
}
#endif /* defined(__minix) */
#ifdef WSCONS_SUPPORT
if( prot == PROT_WSCONS) {
pKbd->consType = WSCONS;

View File

@ -92,7 +92,11 @@ static const char *kbdDefaults[] = {
"Protocol", "standard",
#endif
#else /* NetBSD */
#if defined(__minix)
"Protocol", "mxkbd",
#else
"Protocol", "standard",
#endif /* __minix */
#endif /* NetBSD */
"XkbRules", "base",
"XkbModel", "pc105",

View File

@ -89,6 +89,9 @@ typedef struct {
typedef enum {
PROT_STD,
PROT_WSCONS,
#if defined(__minix)
PROT_MXCONS,
#endif /* defined(__minix) */
PROT_UNKNOWN_KBD
} KbdProtocolId;

View File

@ -36,6 +36,9 @@
#include "mouse.h"
#include "xisb.h"
#include "mipointer.h"
#if defined(__minix)
#include <minix/input.h>
#endif /* defined(__minix) */
#ifdef WSCONS_SUPPORT
#include <dev/wscons/wsconsio.h>
#endif
@ -82,6 +85,12 @@ static const char *mouseDevs[] = {
DEFAULT_PS2_DEV,
NULL
};
#elif defined(__minix)
#define DEFAULT_MOUSEMUX_DEV "/dev/mousemux"
static const char *mouseDevs[] = {
DEFAULT_MOUSEMUX_DEV,
NULL
};
#elif (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT)
/* Only wsmouse mices are autoconfigured for now on OpenBSD */
#define DEFAULT_WSMOUSE_DEV "/dev/wsmouse"
@ -99,6 +108,8 @@ SupportedInterfaces(void)
{
#if defined(__NetBSD__)
return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO | MSE_MISC;
#elif defined(__minix)
return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO | MSE_MISC;
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO | MSE_MISC;
#else
@ -108,6 +119,9 @@ SupportedInterfaces(void)
/* Names of protocols that are handled internally here. */
static const char *internalNames[] = {
#if defined(__minix)
"MinixMouse",
#endif
#if defined(WSCONS_SUPPORT)
"WSMouse",
#endif
@ -153,6 +167,8 @@ DefaultProtocol(void)
{
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
return "Auto";
#elif defined(__minix)
return "Auto";
#elif (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT)
return "WSMouse";
#else
@ -759,10 +775,153 @@ usbPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
}
#endif /* USBMOUSE */
#if defined(__minix)
/* Only support usb mouse configuration for now, through mousemux */
static const char *
SetupAuto(InputInfoPtr pInfo, int *protoPara)
{
xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: protocol is %s\n",
pInfo->name, "MinixMouse");
return "MinixMouse";
}
static void
SetMouseRes(InputInfoPtr pInfo, const char *protocol, int rate, int res)
{
xf86MsgVerb(X_INFO, 3, "%s: SetMouseRes: protocol %s rate %d res %d\n",
pInfo->name, protocol, rate, res);
}
static const char *
FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
{
int fd = -1;
const char **pdev;
for (pdev = mouseDevs; *pdev; pdev++) {
SYSCALL(fd = open(*pdev, O_RDWR | O_NONBLOCK));
if (fd != -1) {
/* Set the Device option. */
pInfo->options =
xf86AddNewOption(pInfo->options,
"Device", *pdev);
xf86Msg(X_INFO, "%s: found Device \"%s\"\n",
pInfo->name, *pdev);
close(fd);
break;
}
}
return *pdev;
}
#define NUMEVENTS 64
#define UMS_BUT(i) ((i) == 0 ? 2 : (i) == 1 ? 0 : (i) == 2 ? 1 : (i))
static void
minixReadInput(InputInfoPtr pInfo)
{
MouseDevPtr pMse;
static struct input_event eventList[NUMEVENTS];
int n, c;
struct input_event *event = eventList;
unsigned char *pBuf;
pMse = pInfo->private;
XisbBlockDuration(pMse->buffer, -1);
pBuf = (unsigned char *)eventList;
n = 0;
while (n < sizeof(eventList) && (c = XisbRead(pMse->buffer)) >= 0) {
pBuf[n++] = (unsigned char)c;
}
if (n == 0)
return;
n /= sizeof(struct input_event);
while( n-- ) {
int buttons = pMse->lastButtons;
int dx = 0, dy = 0, dz = 0, dw = 0, x, y;
switch (event->page) {
case INPUT_PAGE_BUTTON:
if (event->value == INPUT_RELEASE) {
buttons &= ~(1 << UMS_BUT(event->code - 1));
}
if (event->value == INPUT_PRESS) {
buttons |= (1 << UMS_BUT(event->code - 1));
}
break;
case INPUT_PAGE_GD:
if ((event->flags & INPUT_FLAG_REL) == INPUT_FLAG_REL) {
if (event->code == INPUT_GD_X) {
dx += event->value;
}
if (event->code == INPUT_GD_Y) {
dy -= event->value;
}
break;
}
if (event->flags == INPUT_FLAG_ABS) {
miPointerGetPosition (pInfo->dev, &x, &y);
if (event->code == INPUT_GD_X) {
x = event->value;
}
if (event->code == INPUT_GD_Y) {
y = event->value;
}
miPointerSetPosition (pInfo->dev, &x, &y);
xf86PostMotionEvent(pInfo->dev, TRUE, 0, 2, x, y);
++event;
continue;
}
default:
LogMessageVerbSigSafe(X_WARNING, -1,
"%s: bad MinixMouse event: page %04x code %04x value %08x flags %04x devid %04x\n",
pInfo->name, event->page, event->code, event->value, event->flags, event->devid);
++event;
continue;
}
pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw);
++event;
}
return;
}
/* This function is called when the protocol is "wsmouse". */
static Bool
minixPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
{
MouseDevPtr pMse = pInfo->private;
/* Setup the local input proc. */
pInfo->read_input = minixReadInput;
pMse->xisbscale = sizeof(struct input_event);
pMse->invX = 1;
pMse->invY = 1;
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
pInfo->flags |= XI86_CONFIGURED;
#endif
return TRUE;
}
#endif /* defined(__minix) */
static Bool
bsdMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
{
/* The protocol is guaranteed to be one of the internalNames[] */
#ifdef __minix
if (xf86NameCmp(protocol, "MinixMouse") == 0) {
return minixPreInit(pInfo, protocol, flags);
}
#endif
#ifdef WSCONS_SUPPORT
if (xf86NameCmp(protocol, "WSMouse") == 0) {
return wsconsPreInit(pInfo, protocol, flags);
@ -794,11 +953,11 @@ OSMouseInit(int flags)
p->SetBMRes = SetSysMouseRes;
p->SetMiscRes = SetSysMouseRes;
#endif
#if (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT)
#if (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT) || defined(__minix)
p->SetupAuto = SetupAuto;
p->SetMiscRes = SetMouseRes;
#endif
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__minix)
p->FindDevice = FindDevice;
#endif
p->PreInit = bsdMousePreInit;

View File

@ -51,7 +51,7 @@ Revision History:
// typedef __int64 int64_t;
typedef unsigned __int32 uint32_t;
typedef __int32 int32_t;
#elif defined (__linux__) || defined (__NetBSD__) \
#elif defined (__linux__) || defined (__NetBSD__) || defined(__minix) \
|| defined(__sun) || defined(__OpenBSD__) \
|| defined (__FreeBSD__) || defined(__DragonFly__) || defined(__GLIBC__)
typedef unsigned int uint32_t;

View File

@ -27,7 +27,12 @@
#ifndef INTEL_XVMC_H
#define INTEL_XVMC_H
#if !defined(__minix)
#include <pthread.h>
#else
#define _MTHREADIFY_PTHREADS 1
#include <minix/mthread.h>
#endif /* !defined(__minix) */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

View File

@ -39,7 +39,9 @@
#include <fourcc.h>
#include <X11/extensions/Xv.h>
#include <xf86drm.h>
#if !defined(__minix)
#include <pthread.h>
#endif /* !defined(__minix) */
#include "vldXvMC.h"
#include "xf86dri.h"
#include "driDrawable.h"

View File

@ -30,6 +30,10 @@
#include <X11/extensions/XvMClib.h>
#include <stdlib.h>
#include <X11/Xutil.h>
#if defined(__minix)
#define _MTHREADIFY_PTHREADS 1
#include <minix/mthread.h>
#endif /* defined(__minix) */
#include "vldXvMC.h"
#include "via_xvmc.h"

View File

@ -47,7 +47,7 @@ Revision History:
// typedef __int64 int64_t;
typedef unsigned __int32 uint32_t;
typedef __int32 int32_t;
#elif defined (__linux__) || defined (__NetBSD__) \
#elif defined (__linux__) || defined (__NetBSD__) || defined(__minix) \
|| defined(__sun) || defined(__OpenBSD__) \
|| defined (__FreeBSD__) || defined(__DragonFly__) || defined(__GLIBC__)
typedef unsigned int uint32_t;

View File

@ -1010,7 +1010,7 @@ extern void XGI_SetRegANDOR(XGIIOADDRESS Port, USHORT Index, USHORT DataAND,
extern void XGI_SetRegAND(XGIIOADDRESS Port, USHORT Index, USHORT DataAND);
extern void XGI_SetRegOR(XGIIOADDRESS Port, USHORT Index, USHORT DataOR);
#ifndef __NetBSD__
#if !(defined(__NetBSD__) || defined(__minix))
#define uint8_t CARD8
#endif

View File

@ -145,7 +145,9 @@ unsigned char g_DVI_I_SignalType = 0x00;
static int pix24bpp = 0;
int FbDevExist;
#if defined(__minix) && !defined(FBIOGET_FSCREENINFO)
#define FBIOGET_FSCREENINFO 0x4602
#endif /* defined(__minix) && !defined(FBIOGET_FSCREENINFO) */
#define FB_ACCEL_XGI_GLAMOUR 41
struct fb_fix_screeninfo

View File

@ -45,8 +45,10 @@
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
#if !defined(__minix)
/* Support IPv6 for TCP connections */
#define IPv6 1
#endif /* !defined(__minix) */
/* Support os-specific local connections */
/* #undef LOCALCONN */

View File

@ -420,7 +420,9 @@ startServer(char *server[])
* prevent server from getting sighup from vhangup()
* if client is xterm -L
*/
#if !defined(__minix)
setpgid(0,getpid());
#endif /* !defined(__minix) */
Execute(server);
Error("unable to run server \"%s\"", server[0]);
@ -566,7 +568,9 @@ startClient(char *client[])
Error("cannot change uid");
_exit(EXIT_FAILURE);
}
#if !defined(__minix)
setpgid(0, getpid());
#endif /* !defined(__minix) */
Execute(client);
Error("Unable to run program \"%s\"", client[0]);

View File

@ -323,7 +323,7 @@ static __inline__ void stw_u(uint16_t val, uint16_t *p)
# ifndef NO_INLINE
# ifdef __GNUC__
# if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__))
# if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__minix) || defined(__OpenBSD__)) && (defined(__alpha__))
# ifdef linux
/* for Linux on Alpha, we use the LIBC _inx/_outx routines */
@ -393,7 +393,7 @@ extern _X_EXPORT unsigned int inl(unsigned int port);
# endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
#if defined(__NetBSD__)
#if defined(__NetBSD__) || defined(__minix)
#include <machine/pio.h>
#endif /* __NetBSD__ */

View File

@ -62,6 +62,9 @@ static char *DFLT_MOUSE_PROTO = "auto";
#elif defined(linux)
static char DFLT_MOUSE_DEV[] = "/dev/input/mice";
static char DFLT_MOUSE_PROTO[] = "auto";
#elif defined(__minix)
static char *DFLT_MOUSE_DEV = "/dev/mousemux";
static char *DFLT_MOUSE_PROTO = "auto";
#else
static char *DFLT_MOUSE_DEV = "/dev/mouse";
static char *DFLT_MOUSE_PROTO = "auto";
@ -161,6 +164,12 @@ configureInputSection (void)
ptr->inp_identifier = "Keyboard0";
ptr->inp_driver = "kbd";
ptr->list.next = NULL;
#if defined(__minix)
ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
xstrdup("Protocol"), "mxkbd");
ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
xstrdup("Device"), "/dev/kbdmux");
#endif /* defined(__minix) */
#if defined(WSCONS_SUPPORT) && !defined(__i386__) && !defined(__amd64__)
ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
xstrdup("Protocol"), "wskbd");

View File

@ -165,4 +165,8 @@ typedef struct _RootWinProp {
#define WSCONS 32
#endif
#if defined(__minix)
#define MXCONS 64
#endif
#endif /* _XF86PRIVSTR_H */

View File

@ -102,8 +102,10 @@ xf86VTSwitchTo()
Bool
xf86VTActivate(int vtno)
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno) < 0) {
return FALSE;
}
#endif
return TRUE;
}

View File

@ -77,6 +77,10 @@ static Bool ShareVTs = FALSE;
#define WSCONS_PCVT_COMPAT_CONSOLE_DEV "/dev/ttyE0"
#endif
#if defined(__minix)
#define MINIX_CONSOLE_DEV "/dev/video"
#endif /* defined(__minix) */
#ifdef __GLIBC__
#define setpgrp setpgid
#endif
@ -97,6 +101,9 @@ static char *supported_drivers[] = {
#ifdef WSCONS_SUPPORT
"wscons",
#endif
#if defined(__minix)
"minix",
#endif /* defined(__minix) */
};
@ -126,6 +133,10 @@ static int xf86OpenPcvt(void);
static int xf86OpenWScons(void);
#endif
#if defined(__minix)
static int xf86OpenMinixcons(void);
#endif /* defined(__minix) */
/*
* The sequence of the driver probes is important; start with the
* driver that is best distinguishable, and end with the most generic
@ -145,6 +156,9 @@ static xf86ConsOpen_t xf86ConsTab[] = {
#ifdef WSCONS_SUPPORT
xf86OpenWScons,
#endif
#if defined(__minix)
xf86OpenMinixcons,
#endif /* defined(__minix) */
(xf86ConsOpen_t)NULL
};
@ -314,6 +328,11 @@ acquire_vt:
/* Nothing to do */
break;
#endif
#if defined(__minix)
case MXCONS:
/* I don't know what to do. */
break;
#endif /* defined(__minix) */
}
}
else
@ -649,6 +668,25 @@ xf86OpenWScons()
#endif /* WSCONS_SUPPORT */
#if defined(__minix)
static int
xf86OpenMinixcons()
{
int fd = -1;
// O_READONLY == 2 ??
fd = open("/dev/console", 2);
if (fd < 0) {
FatalError("%s: /dev/console failed (%s)\n%s",
"xf86OpenConsole", strerror(errno),
CHECK_DRIVER_MSG);
}
xf86Info.consType = MXCONS;
xf86Msg(X_PROBED, "Using Minix Console driver\n");
return fd;
}
#endif /* defined(__minix) */
void
xf86CloseConsole()
{

View File

@ -78,6 +78,12 @@
"\trefer to xf86(4) for details"
#endif
#if defined(__minix)
#include <minix/type.h>
#include <dev/pci/pciio.h>
static int pci_fd = -1;
#endif /* defined(__minix) */
/***************************************************************************/
/* Video Memory Mapping section */
/***************************************************************************/
@ -122,12 +128,42 @@ checkDevMem(Bool warn)
if ((fd = open(DEV_MEM, O_RDWR)) >= 0)
{
/* Try to map a page at the VGA address */
#if !defined(__minix)
base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
MAP_FLAGS, fd, (off_t)0xA0000);
#else
{
struct pciio_map _map;
int r;
_map.flags = 0;
_map.phys_offset = (phys_bytes)0xA0000;
_map.size = 4096;
_map.readonly = 0;
pci_fd = open("/dev/pci", O_RDWR);
r = ioctl(pci_fd, PCI_IOC_MAP, &_map);
base = _map.vaddr_ret;
if (r < 0) {
base = MAP_FAILED;
}
fprintf(stderr, "%s, base = %08x\n", __func__, (unsigned int)base);
}
#endif /* !defined(__minix) */
if (base != MAP_FAILED)
{
#if !defined(__minix)
munmap((caddr_t)base, 4096);
#else
{
struct pciio_map _map;
_map.size = 4096;
_map.vaddr = base;
ioctl(pci_fd, PCI_IOC_UNMAP, &_map);
}
#endif /* !defined(__minix) */
devMemFd = fd;
useDevMem = TRUE;
return;
@ -236,10 +272,28 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
FatalError("xf86MapVidMem: failed to open %s (%s)",
DEV_MEM, strerror(errno));
}
#if !defined(__minix)
base = mmap((caddr_t)0, Size,
(flags & VIDMEM_READONLY) ?
PROT_READ : (PROT_READ | PROT_WRITE),
MAP_FLAGS, devMemFd, (off_t)Base);
#else
{
struct pciio_map _map;
int r;
_map.flags = 0;
_map.phys_offset = (phys_bytes)Base;
_map.size = Size;
_map.readonly = (flags & VIDMEM_READONLY) ? 1: 0;
r = ioctl(pci_fd, PCI_IOC_MAP, &_map);
base = _map.vaddr_ret;
if (r < 0) {
base = MAP_FAILED;
}
}
#endif /* !defined(__minix) */
if (base == MAP_FAILED)
{
FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)",
@ -272,7 +326,17 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
static void
unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
#if !defined(__minix)
munmap((caddr_t)Base, Size);
#else
{
struct pciio_map _map;
_map.size = Size;
_map.vaddr = Base;
(void)ioctl(pci_fd, PCI_IOC_UNMAP, &_map);
}
#endif /* !defined(__minix) */
}
/*
@ -296,8 +360,26 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
Offset += Base & (psize - 1);
Base &= ~(psize - 1);
mlen = (Offset + Len + psize - 1) & ~(psize - 1);
#if !defined(__minix)
ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
MAP_SHARED, devMemFd, (off_t)Base);
#else
{
struct pciio_map _map;
int r;
_map.flags = 0;
_map.phys_offset = (phys_bytes)Base;
_map.size = mlen;
_map.readonly = 1;
r = ioctl(pci_fd, PCI_IOC_MAP, &_map);
ptr = _map.vaddr_ret;
if (r < 0) {
ptr = MAP_FAILED;
}
}
#endif /* !defined(__minix) */
if ((long)ptr == -1)
{
xf86Msg(X_WARNING,
@ -315,7 +397,17 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
Base, ptr[0] | (ptr[1] << 8));
#endif
(void)memcpy(Buf, (void *)(ptr + Offset), Len);
#if !defined(__minix)
(void)munmap((caddr_t)ptr, mlen);
#else
{
struct pciio_map _map;
_map.size = mlen;
_map.vaddr = ptr;
(void)ioctl(pci_fd, PCI_IOC_UNMAP, &_map);
}
#endif /* !defined(__minix) */
#ifdef DEBUG
xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
"-> %02x %02x %02x %02x...\n",
@ -444,6 +536,33 @@ xf86DisableIO()
#endif
#if defined(__minix)
static int IoFd = -1;
Bool
xf86EnableIO()
{
if (IoFd >= 0)
return TRUE;
if ((IoFd = open("/dev/mem", O_RDWR)) == -1)
{
xf86Msg(X_WARNING,"xf86EnableIO: "
"Failed to open /dev/mem for extended I/O");
return FALSE;
}
return TRUE;
}
void xf86DisableIO()
{
if (IoFd < 0)
return;
close(IoFd);
IoFd = -1;
return;
}
#endif /* defined(__minix) */
#ifdef __NetBSD__
/***************************************************************************/
/* Set TV output mode */

View File

@ -138,7 +138,7 @@
#define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u)
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
defined(__OpenBSD__) || defined(__NetBSD__) || \
defined(__OpenBSD__) || defined(__minix) || defined(__NetBSD__) || \
defined(__DragonFly__) || defined(__sun) || defined(__GNU__)
#define ARCH_PCI_INIT bsdPciInit
#endif

View File

@ -218,7 +218,7 @@
/* 386BSD and derivatives, BSD/386 */
/**************************************************************************/
#if defined(__386BSD__) && (defined(__FreeBSD__) || defined(__NetBSD__))
#if defined(__386BSD__) && (defined(__FreeBSD__) || defined(__minix) || defined(__NetBSD__))
# undef __386BSD__
#endif

View File

@ -752,12 +752,14 @@ DefineSelf (int fd)
)
continue;
#if defined(IFF_LOOPBACK) && defined(__minix)
/*
* ignore 'localhost' entries as they're not useful
* on the other end of the wire
*/
if (ifr->ifa_flags & IFF_LOOPBACK)
continue;
#endif
if (family == FamilyInternet &&
addr[0] == 127 && addr[1] == 0 &&
@ -784,6 +786,7 @@ DefineSelf (int fd)
/* IPv6 doesn't support broadcasting, so we drop out here */
continue;
#endif
#if defined(IFF_BROADCAST) && defined(__minix)
if ((ifr->ifa_flags & IFF_BROADCAST) &&
(ifr->ifa_flags & IFF_UP) &&
ifr->ifa_broadaddr)
@ -791,6 +794,7 @@ DefineSelf (int fd)
(struct sockaddr_in *) ifr->ifa_broadaddr);
else
continue;
#endif
}
#endif /* XDMCP */

View File

@ -247,8 +247,10 @@
/* Define to 1 if you have the `vasprintf' function. */
#define HAVE_VASPRINTF 1
#if !defined(__minix)
/* Support IPv6 for TCP connections */
#define IPv6 1
#endif /* !defined(__minix) */
/* Support os-specific local connections */
/* #undef LOCALCONN */

View File

@ -99,6 +99,7 @@
/* System is BSD-like */
#define CSRG_BASED 1
#if !defined(__minix)
/* System has PC console */
#define PCCONS_SUPPORT 1
@ -110,6 +111,7 @@
/* System has wscons console */
#define WSCONS_SUPPORT 1
#endif /* !defined(__minix) */
/* System has /dev/xf86 aperture driver */
/* #undef HAS_APERTURE_DRV */

View File

@ -164,6 +164,7 @@
/* System is BSD-like */
#define CSRG_BASED 1
#if !defined(__minix)
/* System has PC console */
#define PCCONS_SUPPORT 1
@ -175,6 +176,7 @@
/* System has wscons console */
#define WSCONS_SUPPORT 1
#endif /* !defined(__minix) */
/* Loadable XFree86 server awesomeness */
#define XFree86LOADER 1

View File

@ -141,6 +141,10 @@ typedef unsigned char CARD8;
typedef CARD32 BITS32;
typedef CARD16 BITS16;
#if defined(__minix) && defined(BYTE)
#undef BYTE
#endif /* defined(__minix) && defined(BYTE) */
typedef CARD8 BYTE;
typedef CARD8 BOOL;

View File

@ -248,7 +248,7 @@ typedef struct {
*/
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \
defined(__APPLE__) || defined(__DragonFly__)
defined(__APPLE__) || defined(__DragonFly__) || defined(__minix)
static __inline__ void _Xpw_copyPasswd(_Xgetpwparams p)
{
memcpy(&(p).pws, (p).pwp, sizeof(struct passwd));
@ -403,7 +403,7 @@ typedef int _Xgetservbynameparams; /* dummy */
#elif !defined(XOS_USE_MTSAFE_NETDBAPI) || defined(XNO_MTSAFE_NETDBAPI)
/* WARNING: The h_addr_list and s_aliases values are *not* copied! */
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__minix)
#include <sys/param.h>
#endif

View File

@ -219,7 +219,12 @@ typedef mutex_t xmutex_rec;
# define xcondition_signal(c) cond_signal(c)
# define xcondition_broadcast(c) cond_broadcast(c)
# else
# if defined(__minix)
# define _MTHREADIFY_PTHREADS 1
# include <minix/mthread.h>
# else
# include <pthread.h>
# endif /* defined(__minix) */
typedef pthread_t xthread_t;
typedef pthread_key_t xthread_key_t;
typedef pthread_cond_t xcondition_rec;

View File

@ -123,9 +123,14 @@
#include <ctype.h>
#include <assert.h>
#if !defined(__minix)
#if defined(HAVE_SCHED_YIELD)
#include <sched.h>
#endif
#else
#define _MTHREADIFY_PTHREADS
#include <minix/mthread.h>
#endif /* !defined(__minix) */
#include <VTparse.h>
#include <data.h>

View File

@ -374,8 +374,11 @@ extern struct utmp *getutid __((struct utmp * _Id));
#include <local/openpty.h>
#endif /* PUCC_PTYD */
#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) || defined(__minix)
#include <util.h> /* openpty() */
#if defined(__minix)
#define setpgrp(x, y) /* empty */
#endif /* defined(__minix) */
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
@ -2493,7 +2496,7 @@ main(int argc, char *argv[]ENVP_ARG)
}
#endif
#endif
#if defined(USE_ANY_SYSV_TERMIO) || defined(__MVS__)
#if defined(USE_ANY_SYSV_TERMIO) || defined(__MVS__) || defined(__minix)
if (0 > (mode = fcntl(screen->respond, F_GETFL, 0)))
SysError(ERROR_F_GETFL);
#ifdef O_NDELAY
@ -2583,7 +2586,7 @@ main(int argc, char *argv[]ENVP_ARG)
}
}
#if defined(__osf__) || (defined(__GLIBC__) && !defined(USE_USG_PTYS)) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
#if defined(__osf__) || (defined(__GLIBC__) && !defined(USE_USG_PTYS)) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__minix)
#define USE_OPENPTY 1
static int opened_tty = -1;
#endif
@ -3583,7 +3586,7 @@ spawnXTerm(XtermWidget xw)
/*
* now in child process
*/
#if defined(_POSIX_SOURCE) || defined(SVR4) || defined(__convex__) || defined(__SCO__) || defined(__QNX__)
#if defined(_POSIX_SOURCE) || defined(SVR4) || defined(__convex__) || defined(__SCO__) || defined(__QNX__) || defined(__minix)
int pgrp = setsid(); /* variable may not be used... */
#else
int pgrp = getpid();
@ -3719,7 +3722,9 @@ spawnXTerm(XtermWidget xw)
}
#endif /* USE_NO_DEV_TTY */
#ifdef CSRG_BASED
#if !defined(__minix)
IGNORE_RC(revoke(ttydev));
#endif /* !defined(__minix) */
#endif
if ((ttyfd = open(ttydev, O_RDWR)) >= 0) {
TRACE_TTYSIZE(ttyfd, "after open");

View File

@ -52,7 +52,7 @@
#define USE_SYSV_TERMIO
#endif
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__INTERIX) || defined(__APPLE__) || defined(__UNIXWARE__) || defined(__hpux)
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__INTERIX) || defined(__APPLE__) || defined(__UNIXWARE__) || defined(__hpux) || defined(__minix)
#ifndef USE_POSIX_TERMIOS
#define USE_POSIX_TERMIOS
#endif

View File

@ -53,7 +53,9 @@
/* #undef DISABLE_SETUID */ /* CF_ARG_DISABLE(setuid) */
#define HAVE_GETHOSTNAME 1 /* AC_CHECK_FUNCS(gethostname) */
#define HAVE_GETLOGIN 1 /* AC_CHECK_FUNCS(getlogin) */
#if !defined(__minix)
#define HAVE_GRANTPT 1 /* CF_FUNC_GRANTPT */
#endif /* !defined(__minix) */
/* #undef HAVE_GRANTPT_PTY_ISATTY */ /* CF_FUNC_GRANTPT */
#define HAVE_LANGINFO_CODESET 1 /* AM_LANGINFO_CODESET */
/* #undef HAVE_LASTLOG_H */ /* CF_LASTLOG */
@ -67,9 +69,13 @@
/* #undef HAVE_NCURSES_TERM_H */ /* AC_CHECK_HEADERS(ncurses/term.h) */
#define HAVE_PATHS_H 1 /* CF_LASTLOG */
/* #undef HAVE_PCREPOSIX_H */ /* CF_WITH_PCRE */
#if !defined(__minix)
#define HAVE_POSIX_OPENPT 1 /* CF_FUNC_GRANTPT */
#endif /* !defined(__minix) */
#define HAVE_POSIX_SAVED_IDS 1 /* CF_POSIX_SAVED_IDS */
#if !defined(__minix)
#define HAVE_PTSNAME 1 /* CF_FUNC_GRANTPT */
#endif /* !defined(__minix) */
#define HAVE_PUTENV 1 /* AC_CHECK_FUNCS(putenv) */
#define HAVE_SCHED_YIELD 1 /* AC_CHECK_FUNCS(sched_yield) */
#define HAVE_SETPGID 1 /* AC_CHECK_FUNCS(setpgid) */