~ubuntu-branches/ubuntu/jaunty/ndiswrapper/jaunty

« back to all changes in this revision

Viewing changes to driver/ntoskernel.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-11-21 14:17:35 UTC
  • mfrom: (1.2.11 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20081121141735-hzymcfoy3up8hego
Tags: 1.53-2ubuntu1
* Merge with Debian; remaining changes:
  - Build for lpia.
  - debian/control:
    + Update description to point out that the kernel source package is
      not required with the standard Ubuntu kernel.
    + Change the Maintainer address.
  - debian/control:
    + Drop ndiswrapper-source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include "usb.h"
19
19
#include "pnp.h"
20
20
#include "loader.h"
 
21
#include "ntoskernel_exports.h"
21
22
 
22
23
/* MDLs describe a range of virtual address with an array of physical
23
24
 * pages right after the header. For different ranges of virtual
67
68
static struct nt_thread *ntos_worker_thread;
68
69
spinlock_t irp_cancel_lock;
69
70
static NT_SPIN_LOCK nt_list_lock;
70
 
 
71
 
extern struct nt_list wrap_drivers;
72
71
static struct nt_slist wrap_timer_slist;
73
72
 
74
73
/* compute ticks (100ns) since 1601 until when system booted into
85
84
 
86
85
WIN_SYMBOL_MAP("NlsMbCodePageTag", FALSE)
87
86
 
88
 
#ifdef NTOS_WQ
89
87
workqueue_struct_t *ntos_wq;
90
 
#endif
91
88
 
92
89
#ifdef WRAP_PREEMPT
93
90
DEFINE_PER_CPU(irql_info_t, irql_info);
1445
1442
        return thread;
1446
1443
}
1447
1444
 
1448
 
struct task_struct *get_nt_thread_task(struct nt_thread *thread)
 
1445
static struct task_struct *get_nt_thread_task(struct nt_thread *thread)
1449
1446
{
1450
1447
        struct task_struct *task;
1451
1448
        struct common_object_header *header;
1485
1482
        InitializeListHead(&thread->irps);
1486
1483
        initialize_object(&thread->dh, ThreadObject, 0);
1487
1484
        thread->dh.size = sizeof(*thread);
 
1485
        thread->prio = LOW_PRIORITY;
1488
1486
        return thread;
1489
1487
}
1490
1488
 
1519
1517
                EXIT2(return LOW_REALTIME_PRIORITY);
1520
1518
        }
1521
1519
 
1522
 
        if (thread_priority(thread->task) <= 0)
1523
 
                prio = LOW_PRIORITY;
1524
 
        else if (thread_priority(thread->task) <= -5)
1525
 
                prio = LOW_REALTIME_PRIORITY;
1526
 
        else
1527
 
                prio = MAXIMUM_PRIORITY;
 
1520
        prio = thread->prio;
1528
1521
 
1529
1522
        TRACE2("%d", prio);
1530
1523
        return prio;
1551
1544
                EXIT2(return LOW_REALTIME_PRIORITY);
1552
1545
        }
1553
1546
 
1554
 
        if (thread_priority(task) <= 0)
1555
 
                old_prio = LOW_PRIORITY;
1556
 
        else if (thread_priority(task) <= -5)
1557
 
                old_prio = LOW_REALTIME_PRIORITY;
1558
 
        else
1559
 
                old_prio = MAXIMUM_PRIORITY;
1560
 
 
1561
 
        if (prio == LOW_PRIORITY)
1562
 
                set_thread_priority(task, 0);
1563
 
        else if (prio == LOW_REALTIME_PRIORITY)
1564
 
                set_thread_priority(task, -5);
1565
 
        else if (prio == HIGH_PRIORITY)
1566
 
                set_thread_priority(task, -10);
1567
 
 
1568
 
        TRACE2("%d, %d", old_prio, (int)thread_priority(task));
 
1547
        old_prio = thread->prio;
 
1548
        thread->prio = prio;
 
1549
 
 
1550
        TRACE2("%d, %d", old_prio, thread->prio);
1569
1551
        return old_prio;
1570
1552
}
1571
1553
 
1619
1601
        thread_tramp.ctx = ctx;
1620
1602
        init_completion(&thread_tramp.started);
1621
1603
 
1622
 
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)
1623
 
        thread_tramp.thread->pid = kernel_thread(ntdriver_thread, &thread_tramp,
1624
 
                                                 CLONE_SIGHAND);
1625
 
        TRACE2("pid = %d", thread_tramp.thread->pid);
1626
 
        if (thread_tramp.thread->pid < 0) {
1627
 
                free_object(thread_tramp.thread);
1628
 
                EXIT2(return STATUS_FAILURE);
1629
 
        }
1630
 
        TRACE2("created task: %d", thread_tramp.thread->pid);
1631
 
#else
1632
1604
        thread_tramp.thread->task = kthread_run(ntdriver_thread,
1633
1605
                                                &thread_tramp, "ntdriver");
1634
1606
        if (IS_ERR(thread_tramp.thread->task)) {
1636
1608
                EXIT2(return STATUS_FAILURE);
1637
1609
        }
1638
1610
        TRACE2("created task: %p", thread_tramp.thread->task);
1639
 
#endif
1640
1611
 
1641
1612
        wait_for_completion(&thread_tramp.started);
1642
1613
        *handle = OBJECT_TO_HEADER(thread_tramp.thread);
1715
1686
         PHYSICAL_ADDRESS boundary, enum memory_caching_type cache_type)
1716
1687
{
1717
1688
        void *addr;
1718
 
        unsigned int flags;
 
1689
        gfp_t flags;
1719
1690
 
1720
1691
        ENTER2("%lu, 0x%lx, 0x%lx, 0x%lx, %d", size, (long)lowest,
1721
1692
               (long)highest, (long)boundary, cache_type);
1764
1735
 * probably get this device to work if we create a buffer with the
1765
1736
 * strings as required by the driver and return virtual address for
1766
1737
 * that address instead */
1767
 
wstdcall void *WIN_FUNC(MmMapIoSpace,3)
 
1738
wstdcall void __iomem *WIN_FUNC(MmMapIoSpace,3)
1768
1739
        (PHYSICAL_ADDRESS phys_addr, SIZE_T size,
1769
1740
         enum memory_caching_type cache)
1770
1741
{
1771
 
        void *virt;
 
1742
        void __iomem *virt;
1772
1743
        ENTER1("cache type: %d", cache);
1773
1744
        if (cache == MmCached)
1774
1745
                virt = ioremap(phys_addr, size);
1779
1750
}
1780
1751
 
1781
1752
wstdcall void WIN_FUNC(MmUnmapIoSpace,2)
1782
 
        (void *addr, SIZE_T size)
 
1753
        (void __iomem *addr, SIZE_T size)
1783
1754
{
1784
1755
        ENTER1("%p, %lu", addr, size);
1785
1756
        iounmap(addr);
1985
1956
        return ret;
1986
1957
}
1987
1958
 
1988
 
int dereference_object(void *object)
 
1959
static int dereference_object(void *object)
1989
1960
{
1990
1961
        struct common_object_header *hdr;
1991
1962
        int ref_count;
2464
2435
        TODO();
2465
2436
}
2466
2437
 
2467
 
void WIN_FUNC(_purecall,0)
2468
 
        (void)
2469
 
{
2470
 
        TODO();
2471
 
}
2472
 
 
2473
 
void WIN_FUNC(__chkstk,0)
2474
 
        (void)
2475
 
{
2476
 
        TODO();
2477
 
}
2478
 
 
2479
 
#include "ntoskernel_exports.h"
 
2438
wstdcall void WIN_FUNC(_purecall,0)
 
2439
        (void)
 
2440
{
 
2441
        TODO();
 
2442
}
 
2443
 
 
2444
wstdcall void WIN_FUNC(__chkstk,0)
 
2445
        (void)
 
2446
{
 
2447
        TODO();
 
2448
}
2480
2449
 
2481
2450
struct worker_init_struct {
2482
2451
        work_struct_t work;
2557
2526
        } while (0);
2558
2527
#endif
2559
2528
 
2560
 
#ifdef NTOS_WQ
2561
2529
        ntos_wq = create_singlethread_workqueue("ntos_wq");
2562
2530
        if (!ntos_wq) {
2563
2531
                WARNING("couldn't create ntos_wq thread");
2564
2532
                return -ENOMEM;
2565
2533
        }
2566
2534
        ntos_worker_thread = wrap_worker_init(ntos_wq);
2567
 
#else
2568
 
        ntos_worker_thread = wrap_worker_init(NULL);
2569
 
#endif
2570
2535
        TRACE1("%p", ntos_worker_thread);
2571
2536
 
2572
2537
        if (add_bus_driver("PCI")
2573
 
#ifdef CONFIG_USB
 
2538
#ifdef ENABLE_USB
2574
2539
            || add_bus_driver("USB")
2575
2540
#endif
2576
2541
                ) {
2688
2653
#if defined(CONFIG_X86_64)
2689
2654
        del_timer_sync(&shared_data_timer);
2690
2655
#endif
2691
 
#ifdef NTOS_WQ
2692
2656
        if (ntos_wq)
2693
2657
                destroy_workqueue(ntos_wq);
2694
 
#endif
2695
2658
        TRACE1("%p", ntos_worker_thread);
2696
2659
        if (ntos_worker_thread)
2697
2660
                ObDereferenceObject(ntos_worker_thread);