Commit 54b31229 authored by Benjamin Romer's avatar Benjamin Romer Committed by Greg Kroah-Hartman

staging: unisys: move boottotool out of proc to sysfs

Move the proc entry controlling the boottotool flag to procfs. The field
appears in /sys/devices/platform/visorchipset/install/boottotool.

The boottotool flag controls s-Par behavior on the next boot of this guest.
Setting the flag will cause the guest to boot from the utility and installation
image, which will use the value in the toolaction field to determine what
operation is being requested.
Signed-off-by: default avatarBenjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 19f6634f
...@@ -149,21 +149,12 @@ static ssize_t proc_read_installer(struct file *file, char __user *buf, ...@@ -149,21 +149,12 @@ static ssize_t proc_read_installer(struct file *file, char __user *buf,
static ssize_t proc_write_installer(struct file *file, static ssize_t proc_write_installer(struct file *file,
const char __user *buffer, const char __user *buffer,
size_t count, loff_t *ppos); size_t count, loff_t *ppos);
static ssize_t proc_read_bootToTool(struct file *file, char __user *buf,
size_t len, loff_t *offset);
static ssize_t proc_write_bootToTool(struct file *file,
const char __user *buffer,
size_t count, loff_t *ppos);
static const struct file_operations proc_installer_fops = { static const struct file_operations proc_installer_fops = {
.read = proc_read_installer, .read = proc_read_installer,
.write = proc_write_installer, .write = proc_write_installer,
}; };
static const struct file_operations proc_bootToTool_fops = {
.read = proc_read_bootToTool,
.write = proc_write_bootToTool,
};
typedef struct { typedef struct {
U8 __iomem *ptr; /* pointer to base address of payload pool */ U8 __iomem *ptr; /* pointer to base address of payload pool */
U64 offset; /* offset from beginning of controlvm U64 offset; /* offset from beginning of controlvm
...@@ -318,8 +309,15 @@ static ssize_t toolaction_store(struct device *dev, ...@@ -318,8 +309,15 @@ static ssize_t toolaction_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count); struct device_attribute *attr, const char *buf, size_t count);
static DEVICE_ATTR_RW(toolaction); static DEVICE_ATTR_RW(toolaction);
static ssize_t boottotool_show(struct device *dev,
struct device_attribute *attr, char *buf);
static ssize_t boottotool_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count);
static DEVICE_ATTR_RW(boottotool);
static struct attribute *visorchipset_install_attrs[] = { static struct attribute *visorchipset_install_attrs[] = {
&dev_attr_toolaction.attr, &dev_attr_toolaction.attr,
&dev_attr_boottotool.attr,
NULL NULL
}; };
...@@ -377,6 +375,38 @@ ssize_t toolaction_store(struct device *dev, struct device_attribute *attr, ...@@ -377,6 +375,38 @@ ssize_t toolaction_store(struct device *dev, struct device_attribute *attr,
return -EIO; return -EIO;
} }
ssize_t boottotool_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
ULTRA_EFI_SPAR_INDICATION efiSparIndication;
visorchannel_read(ControlVm_channel,
offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
EfiSparIndication), &efiSparIndication,
sizeof(ULTRA_EFI_SPAR_INDICATION));
return scnprintf(buf, PAGE_SIZE, "%u\n",
efiSparIndication.BootToTool);
}
ssize_t boottotool_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
int val;
ULTRA_EFI_SPAR_INDICATION efiSparIndication;
if (sscanf(buf, "%u\n", &val) == 1) {
efiSparIndication.BootToTool = val;
if (visorchannel_write(ControlVm_channel,
offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
EfiSparIndication),
&(efiSparIndication),
sizeof(ULTRA_EFI_SPAR_INDICATION)) < 0)
return -EFAULT;
else
return count;
} else
return -EIO;
}
static void static void
show_partition_property(struct seq_file *f, void *ctx, int property) show_partition_property(struct seq_file *f, void *ctx, int property)
{ {
...@@ -2408,84 +2438,6 @@ proc_write_installer(struct file *file, ...@@ -2408,84 +2438,6 @@ proc_write_installer(struct file *file,
return count; return count;
} }
/**
* Reads the EfiSparIndication.BootToTool field of ControlVMChannel.
*/
static ssize_t
proc_read_bootToTool(struct file *file, char __user *buf,
size_t len, loff_t *offset)
{
int length = 0;
ULTRA_EFI_SPAR_INDICATION efiSparIndication;
char *vbuf;
loff_t pos = *offset;
if (pos < 0)
return -EINVAL;
if (pos > 0 || !len)
return 0;
vbuf = kzalloc(len, GFP_KERNEL);
if (!vbuf)
return -ENOMEM;
visorchannel_read(ControlVm_channel,
offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
EfiSparIndication), &efiSparIndication,
sizeof(ULTRA_EFI_SPAR_INDICATION));
length = sprintf(vbuf, "%d\n", (int) efiSparIndication.BootToTool);
if (copy_to_user(buf, vbuf, length)) {
kfree(vbuf);
return -EFAULT;
}
kfree(vbuf);
*offset += length;
return length;
}
/**
* Writes to the EfiSparIndication.BootToTool field of ControlVMChannel.
* Input: 1 or 0 (1 being on, 0 being off)
*/
static ssize_t
proc_write_bootToTool(struct file *file,
const char __user *buffer, size_t count, loff_t *ppos)
{
char buf[3];
int inputVal;
ULTRA_EFI_SPAR_INDICATION efiSparIndication;
/* Check to make sure there is no buffer overflow */
if (count > (sizeof(buf) - 1))
return -EINVAL;
if (copy_from_user(buf, buffer, count)) {
WARN(1, "Error copying from user space\n");
return -EFAULT;
}
if (sscanf(buf, "%i", &inputVal) != 1)
inputVal = 0;
efiSparIndication.BootToTool = (inputVal == 1 ? 1 : 0);
if (visorchannel_write
(ControlVm_channel,
offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, EfiSparIndication),
&efiSparIndication, sizeof(ULTRA_EFI_SPAR_INDICATION)) < 0)
printk
("Installation BootToTool Write Failed - BootToTool = %d\n",
(int) efiSparIndication.BootToTool);
/* So this function isn't called multiple times, must return
* size of buffer
*/
return count;
}
static const struct file_operations chipset_proc_fops = { static const struct file_operations chipset_proc_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.read = visorchipset_proc_read_writeonly, .read = visorchipset_proc_read_writeonly,
...@@ -2498,7 +2450,6 @@ visorchipset_init(void) ...@@ -2498,7 +2450,6 @@ visorchipset_init(void)
int rc = 0, x = 0; int rc = 0, x = 0;
char s[64]; char s[64];
struct proc_dir_entry *installer_file; struct proc_dir_entry *installer_file;
struct proc_dir_entry *bootToTool_file;
HOSTADDRESS addr; HOSTADDRESS addr;
if (!unisys_spar_platform) if (!unisys_spar_platform)
...@@ -2575,9 +2526,6 @@ visorchipset_init(void) ...@@ -2575,9 +2526,6 @@ visorchipset_init(void)
/* Setup Installation fields */ /* Setup Installation fields */
installer_file = proc_create("installer", 0644, ProcDir, installer_file = proc_create("installer", 0644, ProcDir,
&proc_installer_fops); &proc_installer_fops);
/* Setup the BootToTool field */
bootToTool_file = proc_create("boottotool", 0644, ProcDir,
&proc_bootToTool_fops);
memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment