/*
* This provides Supervisor channel communication primitives, which are
- * independent of the mechanism used to access the channel data. All channel
- * data is accessed using the memregion abstraction. (memregion has both
- * a CM2 implementation and a direct memory implementation.)
+ * independent of the mechanism used to access the channel data.
*/
-#include "memregion.h"
#include "version.h"
#include "visorbus.h"
#include <linux/uuid.h>
#define MYDRVNAME "visorchannel"
struct visorchannel {
- struct memregion memregion; /* from visor_memregion_create() */
+ HOSTADDRESS physaddr;
+ ulong nbytes;
+ void __iomem *mapped;
struct channel_header chan_hdr;
uuid_le guid;
ulong size;
if (!request_mem_region(physaddr, size, MYDRVNAME))
goto cleanup;
- channel->memregion.mapped = ioremap_cache(physaddr, size);
- if (!channel->memregion.mapped) {
+ channel->mapped = ioremap_cache(physaddr, size);
+ if (!channel->mapped) {
release_mem_region(physaddr, size);
goto cleanup;
}
- channel->memregion.physaddr = physaddr;
- channel->memregion.nbytes = size;
+ channel->physaddr = physaddr;
+ channel->nbytes = size;
err = visorchannel_read(channel, 0, &channel->chan_hdr,
sizeof(struct channel_header));
if (uuid_le_cmp(guid, NULL_UUID_LE) == 0)
guid = channel->chan_hdr.chtype;
- iounmap(channel->memregion.mapped);
- release_mem_region(channel->memregion.physaddr,
- channel->memregion.nbytes);
- channel->memregion.mapped = NULL;
- if (!request_mem_region(channel->memregion.physaddr, channel_bytes,
- MYDRVNAME))
+ iounmap(channel->mapped);
+ release_mem_region(channel->physaddr, channel->nbytes);
+ channel->mapped = NULL;
+ if (!request_mem_region(channel->physaddr, channel_bytes, MYDRVNAME))
goto cleanup;
- channel->memregion.mapped = ioremap_cache(channel->memregion.physaddr,
- channel_bytes);
- if (!channel->memregion.mapped) {
- release_mem_region(channel->memregion.physaddr, channel_bytes);
+ channel->mapped = ioremap_cache(channel->physaddr, channel_bytes);
+ if (!channel->mapped) {
+ release_mem_region(channel->physaddr, channel_bytes);
goto cleanup;
}
- channel->memregion.nbytes = channel_bytes;
+ channel->nbytes = channel_bytes;
channel->size = channel_bytes;
channel->guid = guid;
{
if (!channel)
return;
- if (channel->memregion.mapped) {
- iounmap(channel->memregion.mapped);
- release_mem_region(channel->memregion.physaddr,
- channel->memregion.nbytes);
+ if (channel->mapped) {
+ iounmap(channel->mapped);
+ release_mem_region(channel->physaddr, channel->nbytes);
}
kfree(channel);
}
HOSTADDRESS
visorchannel_get_physaddr(struct visorchannel *channel)
{
- return channel->memregion.physaddr;
+ return channel->physaddr;
}
EXPORT_SYMBOL_GPL(visorchannel_get_physaddr);
visorchannel_read(struct visorchannel *channel, ulong offset,
void *local, ulong nbytes)
{
- if (offset + nbytes > channel->memregion.nbytes)
+ if (offset + nbytes > channel->nbytes)
return -EIO;
- memcpy_fromio(local, channel->memregion.mapped + offset, nbytes);
+ memcpy_fromio(local, channel->mapped + offset, nbytes);
return 0;
}
size_t chdr_size = sizeof(struct channel_header);
size_t copy_size;
- if (offset + nbytes > channel->memregion.nbytes)
+ if (offset + nbytes > channel->nbytes)
return -EIO;
if (offset < chdr_size) {
memcpy(&channel->chan_hdr + offset, local, copy_size);
}
- memcpy_toio(channel->memregion.mapped + offset, local, nbytes);
+ memcpy_toio(channel->mapped + offset, local, nbytes);
return 0;
}
+++ /dev/null
-/* memregion.h
- *
- * 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.
- */
-
-#ifndef __MEMREGION_H__
-#define __MEMREGION_H__
-
-#include "timskmod.h"
-
-/* struct memregion is an opaque structure to users.
- * Fields are declared only in the implementation .c files.
- */
-struct memregion {
- HOSTADDRESS physaddr;
- ulong nbytes;
- void __iomem *mapped;
-};
-
-void memregion_dump(struct memregion *memregion, char *s,
- ulong off, ulong len, struct seq_file *seq);
-
-#endif