patch-2.4.19 linux-2.4.19/arch/ppc64/kernel/HvCall.c
Next file: linux-2.4.19/arch/ppc64/kernel/HvLpConfig.c
Previous file: linux-2.4.19/arch/ppc64/defconfig
Back to the patch index
Back to the overall index
- Lines: 116
- Date:
Fri Aug 2 17:39:43 2002
- Orig file:
linux-2.4.18/arch/ppc64/kernel/HvCall.c
- Orig date:
Wed Dec 31 16:00:00 1969
diff -urN linux-2.4.18/arch/ppc64/kernel/HvCall.c linux-2.4.19/arch/ppc64/kernel/HvCall.c
@@ -0,0 +1,115 @@
+/*
+ * HvCall.c
+ * Copyright (C) 2001 Mike Corrigan IBM Corporation
+ *
+ * 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.
+ */
+
+#include <linux/stddef.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <asm/system.h>
+#include <asm/page.h>
+#include <asm/iSeries/HvCall.h>
+#ifndef _HVCALLSC_H
+#include <asm/iSeries/HvCallSc.h>
+#endif
+#include <asm/iSeries/LparData.h>
+
+#ifndef _HVTYPES_H
+#include <asm/iSeries/HvTypes.h>
+#endif
+
+
+/*=====================================================================
+ * Note that this call takes at MOST one page worth of data
+ */
+int HvCall_readLogBuffer(HvLpIndex lpIndex, void *buffer, u64 bufLen)
+{
+ struct HvLpBufferList *bufList;
+ u64 bytesLeft = bufLen;
+ u64 leftThisPage;
+ u64 curPtr = virt_to_absolute( (unsigned long) buffer );
+ u64 retVal;
+ int npages;
+ int i;
+
+ npages = 0;
+ while (bytesLeft) {
+ npages++;
+ leftThisPage = ((curPtr & PAGE_MASK) + PAGE_SIZE) - curPtr;
+
+ if (leftThisPage > bytesLeft)
+ bytesLeft = 0;
+ else
+ bytesLeft -= leftThisPage;
+
+ curPtr = (curPtr & PAGE_MASK) + PAGE_SIZE;
+ }
+
+ if (npages == 0)
+ return 0;
+
+ bufList = (struct HvLpBufferList *)
+ kmalloc(npages * sizeof(struct HvLpBufferList), GFP_ATOMIC);
+ bytesLeft = bufLen;
+ curPtr = virt_to_absolute( (unsigned long) buffer );
+ for(i=0; i<npages; i++) {
+ bufList[i].addr = curPtr;
+
+ leftThisPage = ((curPtr & PAGE_MASK) + PAGE_SIZE) - curPtr;
+
+ if (leftThisPage > bytesLeft) {
+ bufList[i].len = bytesLeft;
+ bytesLeft = 0;
+ } else {
+ bufList[i].len = leftThisPage;
+ bytesLeft -= leftThisPage;
+ }
+
+ curPtr = (curPtr & PAGE_MASK) + PAGE_SIZE;
+ }
+
+
+ retVal = HvCall3(HvCallBaseReadLogBuffer, lpIndex,
+ virt_to_absolute((unsigned long)bufList), bufLen);
+
+ kfree(bufList);
+
+ return (int)retVal;
+}
+
+/*=====================================================================
+ */
+void HvCall_writeLogBuffer(const void *buffer, u64 bufLen)
+{
+ struct HvLpBufferList bufList;
+ u64 bytesLeft = bufLen;
+ u64 leftThisPage;
+ u64 curPtr = virt_to_absolute( (unsigned long) buffer );
+
+ while (bytesLeft) {
+ bufList.addr = curPtr;
+
+ leftThisPage = ((curPtr & PAGE_MASK) + PAGE_SIZE) - curPtr;
+
+ if (leftThisPage > bytesLeft) {
+ bufList.len = bytesLeft;
+ bytesLeft = 0;
+ } else {
+ bufList.len = leftThisPage;
+ bytesLeft -= leftThisPage;
+ }
+
+ curPtr = (curPtr & PAGE_MASK) + PAGE_SIZE;
+ }
+
+
+ HvCall2(HvCallBaseWriteLogBuffer,
+ virt_to_absolute((unsigned long)&bufList), bufLen);
+
+}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)