#include "timskmod.h"
+
/* PERIODIC_WORK an opaque structure to users.
* Fields are declared only in the implementation .c files.
*/
#include <linux/seq_file.h>
#include <linux/mm.h>
-/* #define DEBUG */
-#if !defined SUCCESS
-#define SUCCESS 0
-#endif
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-#define STRUCTSEQUAL(x, y) (memcmp(&x, &y, sizeof(x)) == 0)
-#ifndef HOSTADDRESS
-#define HOSTADDRESS unsigned long long
-#endif
-
-#define sizeofmember(TYPE, MEMBER) (sizeof(((TYPE *)0)->MEMBER))
-/** "Covered quotient" function */
-#define COVQ(v, d) (((v) + (d) - 1) / (d))
-#define SWAPPOINTERS(p1, p2) \
- do { \
- void *SWAPPOINTERS_TEMP = (void *)p1; \
- (void *)(p1) = (void *)(p2); \
- (void *)(p2) = SWAPPOINTERS_TEMP; \
- } while (0)
-
-#define WARNDRV(fmt, args...) LOGWRN(fmt, ## args)
-#define SECUREDRV(fmt, args...) LOGWRN(fmt, ## args)
-
-#define PRINTKDEV(devname, fmt, args...) LOGINFDEV(devname, fmt, ## args)
-#define TBDDEV(devname, fmt, args...) LOGERRDEV(devname, fmt, ## args)
-#define HUHDEV(devname, fmt, args...) LOGERRDEV(devname, fmt, ## args)
-#define ERRDEV(devname, fmt, args...) LOGERRDEV(devname, fmt, ## args)
-#define ERRDEVX(devno, fmt, args...) LOGERRDEVX(devno, fmt, ## args)
-#define WARNDEV(devname, fmt, args...) LOGWRNDEV(devname, fmt, ## args)
-#define SECUREDEV(devname, fmt, args...) LOGWRNDEV(devname, fmt, ## args)
-#define INFODEV(devname, fmt, args...) LOGINFDEV(devname, fmt, ## args)
-#define INFODEVX(devno, fmt, args...) LOGINFDEVX(devno, fmt, ## args)
-
-/** Verifies the consistency of your PRIVATEDEVICEDATA structure using
- * conventional "signature" fields:
- * <p>
- * - sig1 should contain the size of the structure
- * - sig2 should contain a pointer to the beginning of the structure
- */
-#define DDLOOKSVALID(dd) \
- ((dd != NULL) && \
- ((dd)->sig1 == sizeof(PRIVATEDEVICEDATA)) && \
- ((dd)->sig2 == dd))
-
-/** Verifies the consistency of your PRIVATEFILEDATA structure using
- * conventional "signature" fields:
- * <p>
- * - sig1 should contain the size of the structure
- * - sig2 should contain a pointer to the beginning of the structure
- */
-#define FDLOOKSVALID(fd) \
- ((fd != NULL) && \
- ((fd)->sig1 == sizeof(PRIVATEFILEDATA)) && \
- ((fd)->sig2 == fd))
-
-/** Sleep for an indicated number of seconds (for use in kernel mode).
- * x - the number of seconds to sleep.
- */
-#define SLEEP(x) \
- do { __set_current_state(TASK_INTERRUPTIBLE); \
- schedule_timeout((x)*HZ); \
- } while (0)
-
-/** Sleep for an indicated number of jiffies (for use in kernel mode).
- * x - the number of jiffies to sleep.
- */
-#define SLEEPJIFFIES(x) \
- do { __set_current_state(TASK_INTERRUPTIBLE); \
- schedule_timeout(x); \
- } while (0)
-
-static inline struct cdev *cdev_alloc_init(struct module *owner,
- const struct file_operations *fops)
-{
- struct cdev *cdev = NULL;
-
- cdev = cdev_alloc();
- if (!cdev)
- return NULL;
- cdev->ops = fops;
- cdev->owner = owner;
-
- /* Note that the memory allocated for cdev will be deallocated
- * when the usage count drops to 0, because it is controlled
- * by a kobject of type ktype_cdev_dynamic. (This
- * deallocation could very well happen outside of our kernel
- * module, like via the cdev_put in __fput() for example.)
- */
- return cdev;
-}
-
-extern int unisys_spar_platform;
-
#endif
#include "periodic_work.h"
#include "channel.h"
-#ifndef HOSTADDRESS
-#define HOSTADDRESS u64
-#endif
-
struct visor_driver;
struct visor_device;
* <channel_bytes> and <guid> arguments may be 0 if we are a channel CLIENT.
* In this case, the values can simply be read from the channel header.
*/
-struct visorchannel *visorchannel_create(HOSTADDRESS physaddr,
+struct visorchannel *visorchannel_create(u64 physaddr,
ulong channel_bytes, uuid_le guid);
-struct visorchannel *visorchannel_create_with_lock(HOSTADDRESS physaddr,
+struct visorchannel *visorchannel_create_with_lock(u64 physaddr,
ulong channel_bytes,
uuid_le guid);
void visorchannel_destroy(struct visorchannel *channel);
int visorchannel_signalqueue_slots_avail(struct visorchannel *channel,
u32 queue);
int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue);
-HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel);
+u64 visorchannel_get_physaddr(struct visorchannel *channel);
ulong visorchannel_get_nbytes(struct visorchannel *channel);
char *visorchannel_id(struct visorchannel *channel, char *s);
char *visorchannel_zoneid(struct visorchannel *channel, char *s);
}
static struct visor_device *
-find_visor_device_by_channel(HOSTADDRESS channel_physaddr)
+find_visor_device_by_channel(u64 channel_physaddr)
{
struct list_head *listentry, *listtmp;
* type name
*/
for (i = 0; visordrv->channel_types[i].name; i++) {
- if (STRUCTSEQUAL(visordrv->channel_types[i].guid,
- visordev->channel_type_guid)) {
+ if (memcmp(&visordrv->channel_types[i].guid,
+ &visordev->channel_type_guid,
+ sizeof(visordrv->channel_types[i].guid)) == 0) {
chan_type_name = visordrv->channel_types[i].name;
break;
}
if ((visorchipset_get_bus_info(id, &bus_info)) &&
(bus_info.chan_info.channel_addr > 0) &&
(bus_info.chan_info.n_channel_bytes > 0)) {
- HOSTADDRESS channel_addr = bus_info.chan_info.channel_addr;
+ u64 channel_addr = bus_info.chan_info.channel_addr;
unsigned long n_channel_bytes =
(unsigned long)
bus_info.chan_info.n_channel_bytes;
*/
struct visorchipset_channel_info {
enum visorchipset_addresstype addr_type;
- HOSTADDRESS channel_addr;
+ u64 channel_addr;
struct irq_info intr;
u64 n_channel_bytes;
uuid_le channel_type_uuid;
#define MYDRVNAME "visorchannel"
struct visorchannel {
- HOSTADDRESS physaddr;
+ u64 physaddr;
ulong nbytes;
void __iomem *mapped;
struct channel_header chan_hdr;
* but does NOT modify this data area.
*/
static struct visorchannel *
-visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
+visorchannel_create_guts(u64 physaddr, ulong channel_bytes,
ulong off, uuid_le guid, bool needs_lock)
{
struct visorchannel *channel;
}
struct visorchannel *
-visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid)
+visorchannel_create(u64 physaddr, ulong channel_bytes, uuid_le guid)
{
return visorchannel_create_guts(physaddr, channel_bytes, 0, guid,
false);
EXPORT_SYMBOL_GPL(visorchannel_create);
struct visorchannel *
-visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes,
+visorchannel_create_with_lock(u64 physaddr, ulong channel_bytes,
uuid_le guid)
{
return visorchannel_create_guts(physaddr, channel_bytes, 0, guid,
}
EXPORT_SYMBOL_GPL(visorchannel_destroy);
-HOSTADDRESS
+u64
visorchannel_get_physaddr(struct visorchannel *channel)
{
return channel->physaddr;
}
EXPORT_SYMBOL_GPL(visorchannel_zoneid);
-HOSTADDRESS
+u64
visorchannel_get_clientpartition(struct visorchannel *channel)
{
return channel->chan_hdr.partition_handle;
visorchannel_debug(struct visorchannel *channel, int num_queues,
struct seq_file *seq, u32 off)
{
- HOSTADDRESS addr = 0;
+ u64 addr = 0;
ulong nbytes = 0, nbytes_region = 0;
struct channel_header hdr;
struct channel_header *phdr = &hdr;
#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET 0x00000000
+
+#define UNISYS_SPAR_LEAF_ID 0x40000000
+
+/* The s-Par leaf ID returns "UnisysSpar64" encoded across ebx, ecx, edx */
+#define UNISYS_SPAR_ID_EBX 0x73696e55
+#define UNISYS_SPAR_ID_ECX 0x70537379
+#define UNISYS_SPAR_ID_EDX 0x34367261
+
/*
* Module parameters
*/
* for failure.
*/
static int
-initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes,
+initialize_controlvm_payload_info(u64 phys_addr, u64 offset, u32 bytes,
struct visor_controlvm_payload_info *info)
{
u8 __iomem *payload = NULL;
static void
initialize_controlvm_payload(void)
{
- HOSTADDRESS phys_addr = visorchannel_get_physaddr(controlvm_channel);
+ u64 phys_addr = visorchannel_get_physaddr(controlvm_channel);
u64 payload_offset = 0;
u32 payload_bytes = 0;
* either successfully or with an error.
*/
static bool
-handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
+handle_command(struct controlvm_message inmsg, u64 channel_addr)
{
struct controlvm_message_packet *cmd = &inmsg.cmd;
u64 parm_addr;
return true;
}
-static HOSTADDRESS controlvm_get_channel_address(void)
+static u64 controlvm_get_channel_address(void)
{
u64 addr = 0;
u32 size = 0;
sizeof(vrtc_offset))) {
return -EFAULT;
}
- return SUCCESS;
+ return 0;
case VMCALL_UPDATE_PHYSICAL_TIME:
if (copy_from_user(&adjustment, (void __user *)arg,
sizeof(adjustment))) {
visorchipset_init(struct acpi_device *acpi_device)
{
int rc = 0;
- HOSTADDRESS addr;
+ u64 addr;
memset(&busdev_notifiers, 0, sizeof(busdev_notifiers));
memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info));
{"PNP0A07", 0},
{"", 0},
};
-MODULE_DEVICE_TABLE(acpi, unisys_device_ids);
static struct acpi_driver unisys_acpi_driver = {
.name = "unisys_acpi",
.remove = visorchipset_exit,
},
};
+static __init uint32_t visorutil_spar_detect(void)
+{
+ unsigned int eax, ebx, ecx, edx;
+
+ if (cpu_has_hypervisor) {
+ /* check the ID */
+ cpuid(UNISYS_SPAR_LEAF_ID, &eax, &ebx, &ecx, &edx);
+ return (ebx == UNISYS_SPAR_ID_EBX) &&
+ (ecx == UNISYS_SPAR_ID_ECX) &&
+ (edx == UNISYS_SPAR_ID_EDX);
+ } else {
+ return 0;
+ }
+}
static int init_unisys(void)
{
int result;
-
- if (!unisys_spar_platform)
+ if (!visorutil_spar_detect())
return -ENODEV;
result = acpi_bus_register_driver(&unisys_acpi_driver);
obj-$(CONFIG_UNISYS_VISORUTIL) += visorutil.o
-visorutil-y := charqueue.o periodic_work.o visorkmodutils.o
+visorutil-y := charqueue.o periodic_work.o
ccflags-y += -Idrivers/staging/unisys/include
/*
* Helper functions to schedule periodic work in Linux kernel mode.
*/
+#include <linux/sched.h>
#include "timskmod.h"
#include "periodic_work.h"
}
if (pw->is_scheduled) {
write_unlock(&pw->lock);
- SLEEPJIFFIES(10);
+ __set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(10);
write_lock(&pw->lock);
} else {
pw->want_to_stop = false;
+++ /dev/null
-/* timskmodutils.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-#include "timskmod.h"
-
-#define MYDRVNAME "timskmodutils"
-
-/* s-Par uses the Intel processor's VT-X features to separate groups of
- * processors into partitions. The firmware sets the hypervisor bit and
- * reports an ID in the HV capabilities leaf so that the partition's OS
- * knows s-Par is present and managing the processors.
- */
-
-#define UNISYS_SPAR_LEAF_ID 0x40000000
-
-/* The s-Par leaf ID returns "UnisysSpar64" encoded across ebx, ecx, edx */
-#define UNISYS_SPAR_ID_EBX 0x73696e55
-#define UNISYS_SPAR_ID_ECX 0x70537379
-#define UNISYS_SPAR_ID_EDX 0x34367261
-
-int unisys_spar_platform;
-EXPORT_SYMBOL_GPL(unisys_spar_platform);
-
-static __init uint32_t visorutil_spar_detect(void)
-{
- unsigned int eax, ebx, ecx, edx;
-
- if (cpu_has_hypervisor) {
- /* check the ID */
- cpuid(UNISYS_SPAR_LEAF_ID, &eax, &ebx, &ecx, &edx);
- return (ebx == UNISYS_SPAR_ID_EBX) &&
- (ecx == UNISYS_SPAR_ID_ECX) &&
- (edx == UNISYS_SPAR_ID_EDX);
- } else {
- return 0;
- }
-}
-
-static __init int visorutil_mod_init(void)
-{
- if (visorutil_spar_detect()) {
- unisys_spar_platform = true;
- return 0;
- } else {
- return -ENODEV;
- }
-}
-
-static __exit void
-visorutil_mod_exit(void)
-{
-}
-
-module_init(visorutil_mod_init);
-module_exit(visorutil_mod_exit);
-
-MODULE_LICENSE("GPL");