~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201207201942

« back to all changes in this revision

Viewing changes to modules/linux/vmci/vmciKernelIf.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-10-18 12:28:19 UTC
  • mfrom: (1.1.7 upstream) (2.4.9 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091018122819-00vqew6m0ztpqcqp
Tags: 2009.10.15-201664-1
MergingĀ upstreamĀ versionĀ 2009.10.15-201664.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#error "Wrong platform."
32
32
#endif
33
33
 
 
34
#if !defined(VMX86_TOOLS) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 9)
 
35
#  error "Host Linux kernels before 2.6.9 are not supported."
 
36
#endif
 
37
 
34
38
#define EXPORT_SYMTAB
35
39
#define __NO_VERSION__
36
40
#include "compat_module.h"
1416
1420
                       VMCIQueue *produceQ,              // OUT
1417
1421
                       VMCIQueue *consumeQ)              // OUT
1418
1422
{
1419
 
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
1420
1423
   int retval;
1421
1424
   int err = VMCI_SUCCESS;
1422
1425
 
1501
1504
   }
1502
1505
 
1503
1506
   return err;
1504
 
 
1505
 
#else
1506
 
   /*
1507
 
    * Host queue pair support for earlier kernels temporarily
1508
 
    * disabled. See bug 365496.
1509
 
    */
1510
 
 
1511
 
   ASSERT_NOT_IMPLEMENTED(FALSE);
1512
 
#if 0
1513
 
   attach->produceIoBuf = VMCI_AllocKernelMem(sizeof *attach->produceIoBuf,
1514
 
                                              VMCI_MEMORY_NORMAL);
1515
 
   if (attach->produceIoBuf == NULL) {
1516
 
      return VMCI_ERROR_NO_MEM;
1517
 
   }
1518
 
 
1519
 
   attach->consumeIoBuf = VMCI_AllocKernelMem(sizeof *attach->consumeIoBuf,
1520
 
                                              VMCI_MEMORY_NORMAL);
1521
 
   if (attach->consumeIoBuf == NULL) {
1522
 
      VMCI_FreeKernelMem(attach->produceIoBuf,
1523
 
                         sizeof *attach->produceIoBuf);
1524
 
      return VMCI_ERROR_NO_MEM;
1525
 
   }
1526
 
 
1527
 
   retval = map_user_kiobuf(WRITE, attach->produceIoBuf,
1528
 
                            (VA)attach->produceBuffer,
1529
 
                            attach->numProducePages * PAGE_SIZE);
1530
 
   if (retval < 0) {
1531
 
      err = VMCI_ERROR_NO_ACCESS;
1532
 
      goto out;
1533
 
   }
1534
 
 
1535
 
   retval = map_user_kiobuf(WRITE, attach->consumeIoBuf,
1536
 
                            (VA)attach->consumeBuffer,
1537
 
                            attach->numConsumePages * PAGE_SIZE);
1538
 
   if (retval < 0) {
1539
 
      unmap_kiobuf(attach->produceIoBuf);
1540
 
      err = VMCI_ERROR_NO_ACCESS;
1541
 
   }
1542
 
 
1543
 
   if (err == VMCI_SUCCESS) {
1544
 
      produceQ->queueHeaderPtr = kmap(attach->produceIoBuf->maplist[0]);
1545
 
      produceQ->page = &attach->produceIoBuf->maplist[1];
1546
 
      consumeQ->queueHeaderPtr = kmap(attach->consumeIoBuf->maplist[0]);
1547
 
      consumeQ->page = &attach->consumeIoBuf->maplist[1];
1548
 
   }
1549
 
 
1550
 
out:
1551
 
 
1552
 
   if (err < VMCI_SUCCESS) {
1553
 
      if (attach->produceIoBuf != NULL) {
1554
 
         VMCI_FreeKernelMem(attach->produceIoBuf,
1555
 
                            sizeof *attach->produceIoBuf);
1556
 
      }
1557
 
      if (attach->consumeIoBuf != NULL) {
1558
 
         VMCI_FreeKernelMem(attach->consumeIoBuf,
1559
 
                            sizeof *attach->consumeIoBuf);
1560
 
      }
1561
 
   }
1562
 
 
1563
 
   return err;
1564
 
#else // 0 -- Instead just return FALSE
1565
 
   return FALSE;
1566
 
#endif // 0
1567
 
#endif // Linux version >= 2.6.0
1568
1507
}
1569
1508
 
1570
1509
 
1590
1529
                           VMCIQueue *produceQ,              // OUT
1591
1530
                           VMCIQueue *consumeQ)              // OUT
1592
1531
{
1593
 
 
1594
 
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
1595
1532
   int i;
1596
1533
 
1597
1534
   ASSERT(attach->producePages);
1620
1557
   VMCI_FreeKernelMem(attach->consumePages,
1621
1558
                      attach->numConsumePages *
1622
1559
                      sizeof attach->consumePages[0]);
1623
 
#else
1624
 
   /*
1625
 
    * Host queue pair support for earlier kernels temporarily
1626
 
    * disabled. See bug 365496.
1627
 
    */
1628
 
 
1629
 
   ASSERT_NOT_IMPLEMENTED(FALSE);
1630
 
#if 0
1631
 
   kunmap(attach->produceIoBuf->maplist[0]);
1632
 
   kunmap(attach->consumeIoBuf->maplist[0]);
1633
 
 
1634
 
   mark_dirty_kiobuf(attach->produceIoBuf,
1635
 
                     attach->numProducePages * PAGE_SIZE);
1636
 
   unmap_kiobuf(attach->produceIoBuf);
1637
 
 
1638
 
   mark_dirty_kiobuf(attach->consumeIoBuf,
1639
 
                     attach->numConsumePages * PAGE_SIZE);
1640
 
   unmap_kiobuf(attach->consumeIoBuf);
1641
 
 
1642
 
   VMCI_FreeKernelMem(attach->produceIoBuf,
1643
 
                      sizeof *attach->produceIoBuf);
1644
 
   VMCI_FreeKernelMem(attach->consumeIoBuf,
1645
 
                      sizeof *attach->consumeIoBuf);
1646
 
#endif
1647
 
#endif
1648
1560
}
1649
1561
 
1650
 
#endif
 
1562
#endif  /* Host only code */