Subversion Repositories Kolibri OS

Rev

Rev 1498 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1498 serge 1
/******************************************************************************
2
 *
3
 * Module Name: oswinxf - Windows OSL
4
 *
5
 *****************************************************************************/
6
 
7
/******************************************************************************
8
 *
9
 * 1. Copyright Notice
10
 *
2216 Serge 11
 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
1498 serge 12
 * All rights reserved.
13
 *
14
 * 2. License
15
 *
16
 * 2.1. This is your license from Intel Corp. under its intellectual property
17
 * rights.  You may have additional license terms from the party that provided
18
 * you this software, covering your right to use that party's intellectual
19
 * property rights.
20
 *
21
 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22
 * copy of the source code appearing in this file ("Covered Code") an
23
 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24
 * base code distributed originally by Intel ("Original Intel Code") to copy,
25
 * make derivatives, distribute, use and display any portion of the Covered
26
 * Code in any form, with the right to sublicense such rights; and
27
 *
28
 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29
 * license (with the right to sublicense), under only those claims of Intel
30
 * patents that are infringed by the Original Intel Code, to make, use, sell,
31
 * offer to sell, and import the Covered Code and derivative works thereof
32
 * solely to the minimum extent necessary to exercise the above copyright
33
 * license, and in no event shall the patent license extend to any additions
34
 * to or modifications of the Original Intel Code.  No other license or right
35
 * is granted directly or by implication, estoppel or otherwise;
36
 *
37
 * The above copyright and patent license is granted only if the following
38
 * conditions are met:
39
 *
40
 * 3. Conditions
41
 *
42
 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43
 * Redistribution of source code of any substantial portion of the Covered
44
 * Code or modification with rights to further distribute source must include
45
 * the above Copyright Notice, the above License, this list of Conditions,
46
 * and the following Disclaimer and Export Compliance provision.  In addition,
47
 * Licensee must cause all Covered Code to which Licensee contributes to
48
 * contain a file documenting the changes Licensee made to create that Covered
49
 * Code and the date of any change.  Licensee must include in that file the
50
 * documentation of any changes made by any predecessor Licensee.  Licensee
51
 * must include a prominent statement that the modification is derived,
52
 * directly or indirectly, from Original Intel Code.
53
 *
54
 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55
 * Redistribution of source code of any substantial portion of the Covered
56
 * Code or modification without rights to further distribute source must
57
 * include the following Disclaimer and Export Compliance provision in the
58
 * documentation and/or other materials provided with distribution.  In
59
 * addition, Licensee may not authorize further sublicense of source of any
60
 * portion of the Covered Code, and must include terms to the effect that the
61
 * license from Licensee to its licensee is limited to the intellectual
62
 * property embodied in the software Licensee provides to its licensee, and
63
 * not to intellectual property embodied in modifications its licensee may
64
 * make.
65
 *
66
 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67
 * substantial portion of the Covered Code or modification must reproduce the
68
 * above Copyright Notice, and the following Disclaimer and Export Compliance
69
 * provision in the documentation and/or other materials provided with the
70
 * distribution.
71
 *
72
 * 3.4. Intel retains all right, title, and interest in and to the Original
73
 * Intel Code.
74
 *
75
 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76
 * Intel shall be used in advertising or otherwise to promote the sale, use or
77
 * other dealings in products derived from or relating to the Covered Code
78
 * without prior written authorization from Intel.
79
 *
80
 * 4. Disclaimer and Export Compliance
81
 *
82
 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83
 * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84
 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
85
 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
86
 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
87
 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88
 * PARTICULAR PURPOSE.
89
 *
90
 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91
 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92
 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93
 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94
 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95
 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
96
 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97
 * LIMITED REMEDY.
98
 *
99
 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100
 * software or system incorporating such software without first obtaining any
101
 * required license or other approval from the U. S. Department of Commerce or
102
 * any other agency or department of the United States Government.  In the
103
 * event Licensee exports any such software from the United States or
104
 * re-exports any such software from a foreign destination, Licensee shall
105
 * ensure that the distribution and export/re-export of the software is in
106
 * compliance with all laws, regulations, orders, or other restrictions of the
107
 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108
 * any of its subsidiaries will export/re-export any technical data, process,
109
 * software, or service, directly or indirectly, to any country for which the
110
 * United States government or any agency thereof requires an export license,
111
 * other governmental approval, or letter of assurance, without first obtaining
112
 * such license, approval or letter.
113
 *
114
 *****************************************************************************/
115
 
2216 Serge 116
#include "acpi.h"
117
#include "accommon.h"
1498 serge 118
 
119
#ifdef WIN32
120
#pragma warning(disable:4115)   /* warning C4115: named type definition in parentheses (caused by rpcasync.h> */
121
 
122
#include 
123
#include 
124
 
125
#elif WIN64
126
#include 
127
#endif
128
 
129
#include 
130
#include 
131
#include 
132
#include 
133
#include 
134
 
135
#define _COMPONENT          ACPI_OS_SERVICES
136
        ACPI_MODULE_NAME    ("oswinxf")
137
 
138
 
2216 Serge 139
extern FILE                 *AcpiGbl_DebugFile;
140
extern BOOLEAN              AcpiGbl_DebugTimeout;
1498 serge 141
 
2216 Serge 142
FILE                        *AcpiGbl_OutputFile;
143
UINT64                      TimerFrequency;
144
char                        TableName[ACPI_NAME_SIZE + 1];
1498 serge 145
 
2216 Serge 146
#define ACPI_OS_DEBUG_TIMEOUT   30000 /* 30 seconds */
1498 serge 147
 
148
 
2216 Serge 149
/* Upcalls to application */
1498 serge 150
 
151
ACPI_PHYSICAL_ADDRESS
152
AeLocalGetRootPointer (
153
    void);
154
 
155
void
156
AeTableOverride (
157
    ACPI_TABLE_HEADER       *ExistingTable,
158
    ACPI_TABLE_HEADER       **NewTable);
159
 
160
ACPI_TABLE_HEADER *
161
OsGetTable (
162
    char                    *Signature);
163
 
164
 
2216 Serge 165
/*
166
 * Real semaphores are only used for a multi-threaded application
167
 */
168
#ifndef ACPI_SINGLE_THREADED
1498 serge 169
 
2216 Serge 170
/* Semaphore information structure */
1498 serge 171
 
2216 Serge 172
typedef struct acpi_os_semaphore_info
173
{
174
    UINT16                  MaxUnits;
175
    UINT16                  CurrentUnits;
176
    void                    *OsHandle;
1498 serge 177
 
2216 Serge 178
} ACPI_OS_SEMAPHORE_INFO;
1498 serge 179
 
2216 Serge 180
/* Need enough semaphores to run the large aslts suite */
181
 
182
#define ACPI_OS_MAX_SEMAPHORES  256
183
 
184
ACPI_OS_SEMAPHORE_INFO          AcpiGbl_Semaphores[ACPI_OS_MAX_SEMAPHORES];
185
 
186
#endif /* ACPI_SINGLE_THREADED */
187
 
188
 
1498 serge 189
/******************************************************************************
190
 *
191
 * FUNCTION:    AcpiOsTerminate
192
 *
193
 * PARAMETERS:  None
194
 *
2216 Serge 195
 * RETURN:      Status
1498 serge 196
 *
197
 * DESCRIPTION: Nothing to do for windows
198
 *
199
 *****************************************************************************/
200
 
201
ACPI_STATUS
2216 Serge 202
AcpiOsTerminate (
203
    void)
1498 serge 204
{
2216 Serge 205
    return (AE_OK);
1498 serge 206
}
207
 
208
 
209
/******************************************************************************
210
 *
211
 * FUNCTION:    AcpiOsInitialize
212
 *
213
 * PARAMETERS:  None
214
 *
215
 * RETURN:      Status
216
 *
217
 * DESCRIPTION: Init this OSL
218
 *
219
 *****************************************************************************/
220
 
221
ACPI_STATUS
2216 Serge 222
AcpiOsInitialize (
223
    void)
1498 serge 224
{
225
    LARGE_INTEGER           LocalTimerFrequency;
226
 
227
 
2216 Serge 228
#ifndef ACPI_SINGLE_THREADED
1498 serge 229
    /* Clear the semaphore info array */
230
 
231
    memset (AcpiGbl_Semaphores, 0x00, sizeof (AcpiGbl_Semaphores));
2216 Serge 232
#endif
1498 serge 233
 
2216 Serge 234
    AcpiGbl_OutputFile = stdout;
235
 
1498 serge 236
    /* Get the timer frequency for use in AcpiOsGetTimer */
237
 
238
    TimerFrequency = 0;
239
    if (QueryPerformanceFrequency (&LocalTimerFrequency))
240
    {
241
        /* Frequency is in ticks per second */
242
 
243
        TimerFrequency = LocalTimerFrequency.QuadPart;
244
    }
245
 
2216 Serge 246
    return (AE_OK);
1498 serge 247
}
248
 
249
 
250
/******************************************************************************
251
 *
252
 * FUNCTION:    AcpiOsGetRootPointer
253
 *
254
 * PARAMETERS:  None
255
 *
256
 * RETURN:      RSDP physical address
257
 *
258
 * DESCRIPTION: Gets the root pointer (RSDP)
259
 *
260
 *****************************************************************************/
261
 
262
ACPI_PHYSICAL_ADDRESS
263
AcpiOsGetRootPointer (
264
    void)
265
{
266
 
267
    return (AeLocalGetRootPointer ());
268
}
269
 
270
 
271
/******************************************************************************
272
 *
273
 * FUNCTION:    AcpiOsPredefinedOverride
274
 *
2216 Serge 275
 * PARAMETERS:  InitVal             - Initial value of the predefined object
276
 *              NewVal              - The new value for the object
1498 serge 277
 *
2216 Serge 278
 * RETURN:      Status, pointer to value. Null pointer returned if not
1498 serge 279
 *              overriding.
280
 *
281
 * DESCRIPTION: Allow the OS to override predefined names
282
 *
283
 *****************************************************************************/
284
 
285
ACPI_STATUS
286
AcpiOsPredefinedOverride (
287
    const ACPI_PREDEFINED_NAMES *InitVal,
288
    ACPI_STRING                 *NewVal)
289
{
290
 
291
    if (!InitVal || !NewVal)
292
    {
293
        return (AE_BAD_PARAMETER);
294
    }
295
 
296
    *NewVal = NULL;
297
    return (AE_OK);
298
}
299
 
300
 
301
/******************************************************************************
302
 *
303
 * FUNCTION:    AcpiOsTableOverride
304
 *
2216 Serge 305
 * PARAMETERS:  ExistingTable       - Header of current table (probably firmware)
306
 *              NewTable            - Where an entire new table is returned.
1498 serge 307
 *
2216 Serge 308
 * RETURN:      Status, pointer to new table. Null pointer returned if no
1498 serge 309
 *              table is available to override
310
 *
311
 * DESCRIPTION: Return a different version of a table if one is available
312
 *
313
 *****************************************************************************/
314
 
315
ACPI_STATUS
316
AcpiOsTableOverride (
317
    ACPI_TABLE_HEADER       *ExistingTable,
318
    ACPI_TABLE_HEADER       **NewTable)
319
{
320
 
321
    if (!ExistingTable || !NewTable)
322
    {
323
        return (AE_BAD_PARAMETER);
324
    }
325
 
326
    *NewTable = NULL;
327
 
328
 
329
#ifdef ACPI_EXEC_APP
330
 
331
    /* Call back up to AcpiExec */
332
 
333
    AeTableOverride (ExistingTable, NewTable);
334
#endif
335
 
336
 
337
#ifdef ACPI_ASL_COMPILER
338
 
339
    /* Attempt to get the table from the registry */
340
 
341
    /* Construct a null-terminated string from table signature */
342
 
343
    TableName[ACPI_NAME_SIZE] = 0;
344
    ACPI_STRNCPY (TableName, ExistingTable->Signature, ACPI_NAME_SIZE);
345
 
346
    *NewTable = OsGetTable (TableName);
347
    if (*NewTable)
348
    {
349
        AcpiOsPrintf ("Table [%s] obtained from registry, %u bytes\n",
350
            TableName, (*NewTable)->Length);
351
    }
352
    else
353
    {
354
        AcpiOsPrintf ("Could not read table %s from registry\n", TableName);
355
    }
356
#endif
357
 
358
    return (AE_OK);
359
}
360
 
361
 
362
/******************************************************************************
363
 *
364
 * FUNCTION:    AcpiOsGetTimer
365
 *
366
 * PARAMETERS:  None
367
 *
368
 * RETURN:      Current ticks in 100-nanosecond units
369
 *
370
 * DESCRIPTION: Get the value of a system timer
371
 *
372
 ******************************************************************************/
373
 
374
UINT64
375
AcpiOsGetTimer (
376
    void)
377
{
378
    LARGE_INTEGER           Timer;
379
 
380
 
381
    /* Attempt to use hi-granularity timer first */
382
 
383
    if (TimerFrequency &&
384
        QueryPerformanceCounter (&Timer))
385
    {
386
        /* Convert to 100 nanosecond ticks */
387
 
388
        return ((UINT64) ((Timer.QuadPart * (UINT64) 10000000) / TimerFrequency));
389
    }
390
 
391
    /* Fall back to the lo-granularity timer */
392
 
393
    else
394
    {
395
        /* Convert milliseconds to 100 nanosecond ticks */
396
 
397
        return ((UINT64) GetTickCount() * 10000);
398
    }
399
}
400
 
401
 
402
/******************************************************************************
403
 *
404
 * FUNCTION:    AcpiOsReadable
405
 *
406
 * PARAMETERS:  Pointer             - Area to be verified
407
 *              Length              - Size of area
408
 *
409
 * RETURN:      TRUE if readable for entire length
410
 *
411
 * DESCRIPTION: Verify that a pointer is valid for reading
412
 *
413
 *****************************************************************************/
414
 
415
BOOLEAN
416
AcpiOsReadable (
417
    void                    *Pointer,
418
    ACPI_SIZE               Length)
419
{
420
 
421
    return ((BOOLEAN) !IsBadReadPtr (Pointer, Length));
422
}
423
 
424
 
425
/******************************************************************************
426
 *
427
 * FUNCTION:    AcpiOsWritable
428
 *
429
 * PARAMETERS:  Pointer             - Area to be verified
430
 *              Length              - Size of area
431
 *
432
 * RETURN:      TRUE if writable for entire length
433
 *
434
 * DESCRIPTION: Verify that a pointer is valid for writing
435
 *
436
 *****************************************************************************/
437
 
438
BOOLEAN
439
AcpiOsWritable (
440
    void                    *Pointer,
441
    ACPI_SIZE               Length)
442
{
443
 
444
    return ((BOOLEAN) !IsBadWritePtr (Pointer, Length));
445
}
446
 
447
 
448
/******************************************************************************
449
 *
450
 * FUNCTION:    AcpiOsRedirectOutput
451
 *
452
 * PARAMETERS:  Destination         - An open file handle/pointer
453
 *
454
 * RETURN:      None
455
 *
456
 * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf
457
 *
458
 *****************************************************************************/
459
 
460
void
461
AcpiOsRedirectOutput (
462
    void                    *Destination)
463
{
464
 
465
    AcpiGbl_OutputFile = Destination;
466
}
467
 
468
 
469
/******************************************************************************
470
 *
471
 * FUNCTION:    AcpiOsPrintf
472
 *
2216 Serge 473
 * PARAMETERS:  Fmt, ...            - Standard printf format
1498 serge 474
 *
475
 * RETURN:      None
476
 *
477
 * DESCRIPTION: Formatted output
478
 *
479
 *****************************************************************************/
480
 
481
void ACPI_INTERNAL_VAR_XFACE
482
AcpiOsPrintf (
483
    const char              *Fmt,
484
    ...)
485
{
486
    va_list                 Args;
487
 
488
 
489
    va_start (Args, Fmt);
490
 
491
    AcpiOsVprintf (Fmt, Args);
492
 
493
    va_end (Args);
494
    return;
495
}
496
 
497
 
498
/******************************************************************************
499
 *
500
 * FUNCTION:    AcpiOsVprintf
501
 *
2216 Serge 502
 * PARAMETERS:  Fmt                 - Standard printf format
503
 *              Args                - Argument list
1498 serge 504
 *
505
 * RETURN:      None
506
 *
507
 * DESCRIPTION: Formatted output with argument list pointer
508
 *
509
 *****************************************************************************/
510
 
511
void
512
AcpiOsVprintf (
513
    const char              *Fmt,
514
    va_list                 Args)
515
{
516
    INT32                   Count = 0;
517
    UINT8                   Flags;
518
 
519
 
520
    Flags = AcpiGbl_DbOutputFlags;
521
    if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT)
522
    {
523
        /* Output is directable to either a file (if open) or the console */
524
 
525
        if (AcpiGbl_DebugFile)
526
        {
527
            /* Output file is open, send the output there */
528
 
529
            Count = vfprintf (AcpiGbl_DebugFile, Fmt, Args);
530
        }
531
        else
532
        {
533
            /* No redirection, send output to console (once only!) */
534
 
535
            Flags |= ACPI_DB_CONSOLE_OUTPUT;
536
        }
537
    }
538
 
539
    if (Flags & ACPI_DB_CONSOLE_OUTPUT)
540
    {
541
        Count = vfprintf (AcpiGbl_OutputFile, Fmt, Args);
542
    }
543
 
544
    return;
545
}
546
 
547
 
548
/******************************************************************************
549
 *
550
 * FUNCTION:    AcpiOsGetLine
551
 *
2216 Serge 552
 * PARAMETERS:  Buffer              - Where to return the command line
553
 *              BufferLength        - Maximum length of Buffer
554
 *              BytesRead           - Where the actual byte count is returned
1498 serge 555
 *
2216 Serge 556
 * RETURN:      Status and actual bytes read
1498 serge 557
 *
558
 * DESCRIPTION: Formatted input with argument list pointer
559
 *
560
 *****************************************************************************/
561
 
2216 Serge 562
ACPI_STATUS
1498 serge 563
AcpiOsGetLine (
2216 Serge 564
    char                    *Buffer,
565
    UINT32                  BufferLength,
566
    UINT32                  *BytesRead)
1498 serge 567
{
568
    char                    Temp;
569
    UINT32                  i;
570
 
571
 
572
    for (i = 0; ; i++)
573
    {
2216 Serge 574
        if (i >= BufferLength)
575
        {
576
            return (AE_BUFFER_OVERFLOW);
577
        }
578
 
1498 serge 579
        scanf ("%1c", &Temp);
580
        if (!Temp || Temp == '\n')
581
        {
582
            break;
583
        }
584
 
585
        Buffer [i] = Temp;
586
    }
587
 
588
    /* Null terminate the buffer */
589
 
590
    Buffer [i] = 0;
591
 
592
    /* Return the number of bytes in the string */
593
 
2216 Serge 594
    if (BytesRead)
595
    {
596
        *BytesRead = i;
597
    }
598
    return (AE_OK);
1498 serge 599
}
600
 
601
 
602
/******************************************************************************
603
 *
604
 * FUNCTION:    AcpiOsMapMemory
605
 *
2216 Serge 606
 * PARAMETERS:  Where               - Physical address of memory to be mapped
607
 *              Length              - How much memory to map
1498 serge 608
 *
2216 Serge 609
 * RETURN:      Pointer to mapped memory. Null on error.
1498 serge 610
 *
611
 * DESCRIPTION: Map physical memory into caller's address space
612
 *
613
 *****************************************************************************/
614
 
615
void *
616
AcpiOsMapMemory (
2216 Serge 617
    ACPI_PHYSICAL_ADDRESS   Where,
618
    ACPI_SIZE               Length)
1498 serge 619
{
620
 
2216 Serge 621
    return (ACPI_TO_POINTER ((ACPI_SIZE) Where));
1498 serge 622
}
623
 
624
 
625
/******************************************************************************
626
 *
627
 * FUNCTION:    AcpiOsUnmapMemory
628
 *
2216 Serge 629
 * PARAMETERS:  Where               - Logical address of memory to be unmapped
630
 *              Length              - How much memory to unmap
1498 serge 631
 *
632
 * RETURN:      None.
633
 *
2216 Serge 634
 * DESCRIPTION: Delete a previously created mapping. Where and Length must
1498 serge 635
 *              correspond to a previous mapping exactly.
636
 *
637
 *****************************************************************************/
638
 
639
void
640
AcpiOsUnmapMemory (
2216 Serge 641
    void                    *Where,
642
    ACPI_SIZE               Length)
1498 serge 643
{
644
 
645
    return;
646
}
647
 
648
 
649
/******************************************************************************
650
 *
651
 * FUNCTION:    AcpiOsAllocate
652
 *
2216 Serge 653
 * PARAMETERS:  Size                - Amount to allocate, in bytes
1498 serge 654
 *
2216 Serge 655
 * RETURN:      Pointer to the new allocation. Null on error.
1498 serge 656
 *
2216 Serge 657
 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS.
1498 serge 658
 *
659
 *****************************************************************************/
660
 
661
void *
662
AcpiOsAllocate (
2216 Serge 663
    ACPI_SIZE               Size)
1498 serge 664
{
665
    void                    *Mem;
666
 
667
 
2216 Serge 668
    Mem = (void *) malloc ((size_t) Size);
1498 serge 669
 
2216 Serge 670
    return (Mem);
1498 serge 671
}
672
 
673
 
674
/******************************************************************************
675
 *
676
 * FUNCTION:    AcpiOsFree
677
 *
2216 Serge 678
 * PARAMETERS:  Mem                 - Pointer to previously allocated memory
1498 serge 679
 *
680
 * RETURN:      None.
681
 *
682
 * DESCRIPTION: Free memory allocated via AcpiOsAllocate
683
 *
684
 *****************************************************************************/
685
 
686
void
687
AcpiOsFree (
688
    void                    *Mem)
689
{
690
 
691
    free (Mem);
692
}
693
 
694
 
2216 Serge 695
#ifdef ACPI_SINGLE_THREADED
1498 serge 696
/******************************************************************************
697
 *
2216 Serge 698
 * FUNCTION:    Semaphore stub functions
699
 *
700
 * DESCRIPTION: Stub functions used for single-thread applications that do
701
 *              not require semaphore synchronization. Full implementations
702
 *              of these functions appear after the stubs.
703
 *
704
 *****************************************************************************/
705
 
706
ACPI_STATUS
707
AcpiOsCreateSemaphore (
708
    UINT32              MaxUnits,
709
    UINT32              InitialUnits,
710
    ACPI_HANDLE         *OutHandle)
711
{
712
    *OutHandle = (ACPI_HANDLE) 1;
713
    return (AE_OK);
714
}
715
 
716
ACPI_STATUS
717
AcpiOsDeleteSemaphore (
718
    ACPI_HANDLE         Handle)
719
{
720
    return (AE_OK);
721
}
722
 
723
ACPI_STATUS
724
AcpiOsWaitSemaphore (
725
    ACPI_HANDLE         Handle,
726
    UINT32              Units,
727
    UINT16              Timeout)
728
{
729
    return (AE_OK);
730
}
731
 
732
ACPI_STATUS
733
AcpiOsSignalSemaphore (
734
    ACPI_HANDLE         Handle,
735
    UINT32              Units)
736
{
737
    return (AE_OK);
738
}
739
 
740
#else
741
/******************************************************************************
742
 *
1498 serge 743
 * FUNCTION:    AcpiOsCreateSemaphore
744
 *
745
 * PARAMETERS:  MaxUnits            - Maximum units that can be sent
746
 *              InitialUnits        - Units to be assigned to the new semaphore
747
 *              OutHandle           - Where a handle will be returned
748
 *
749
 * RETURN:      Status
750
 *
751
 * DESCRIPTION: Create an OS semaphore
752
 *
753
 *****************************************************************************/
754
 
755
ACPI_STATUS
756
AcpiOsCreateSemaphore (
757
    UINT32              MaxUnits,
758
    UINT32              InitialUnits,
759
    ACPI_SEMAPHORE      *OutHandle)
760
{
761
    void                *Mutex;
762
    UINT32              i;
763
 
764
    ACPI_FUNCTION_NAME (OsCreateSemaphore);
765
 
766
 
767
    if (MaxUnits == ACPI_UINT32_MAX)
768
    {
769
        MaxUnits = 255;
770
    }
771
 
772
    if (InitialUnits == ACPI_UINT32_MAX)
773
    {
774
        InitialUnits = MaxUnits;
775
    }
776
 
777
    if (InitialUnits > MaxUnits)
778
    {
2216 Serge 779
        return (AE_BAD_PARAMETER);
1498 serge 780
    }
781
 
782
    /* Find an empty slot */
783
 
784
    for (i = 0; i < ACPI_OS_MAX_SEMAPHORES; i++)
785
    {
786
        if (!AcpiGbl_Semaphores[i].OsHandle)
787
        {
788
            break;
789
        }
790
    }
791
    if (i >= ACPI_OS_MAX_SEMAPHORES)
792
    {
793
        ACPI_EXCEPTION ((AE_INFO, AE_LIMIT,
794
            "Reached max semaphores (%u), could not create", ACPI_OS_MAX_SEMAPHORES));
2216 Serge 795
        return (AE_LIMIT);
1498 serge 796
    }
797
 
798
    /* Create an OS semaphore */
799
 
800
    Mutex = CreateSemaphore (NULL, InitialUnits, MaxUnits, NULL);
801
    if (!Mutex)
802
    {
803
        ACPI_ERROR ((AE_INFO, "Could not create semaphore"));
2216 Serge 804
        return (AE_NO_MEMORY);
1498 serge 805
    }
806
 
807
    AcpiGbl_Semaphores[i].MaxUnits = (UINT16) MaxUnits;
808
    AcpiGbl_Semaphores[i].CurrentUnits = (UINT16) InitialUnits;
809
    AcpiGbl_Semaphores[i].OsHandle = Mutex;
810
 
811
    ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Handle=%u, Max=%u, Current=%u, OsHandle=%p\n",
812
            i, MaxUnits, InitialUnits, Mutex));
813
 
814
    *OutHandle = (void *) i;
2216 Serge 815
    return (AE_OK);
1498 serge 816
}
817
 
818
 
819
/******************************************************************************
820
 *
821
 * FUNCTION:    AcpiOsDeleteSemaphore
822
 *
823
 * PARAMETERS:  Handle              - Handle returned by AcpiOsCreateSemaphore
824
 *
825
 * RETURN:      Status
826
 *
827
 * DESCRIPTION: Delete an OS semaphore
828
 *
829
 *****************************************************************************/
830
 
831
ACPI_STATUS
832
AcpiOsDeleteSemaphore (
833
    ACPI_SEMAPHORE      Handle)
834
{
835
    UINT32              Index = (UINT32) Handle;
836
 
837
 
838
    if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
839
        !AcpiGbl_Semaphores[Index].OsHandle)
840
    {
2216 Serge 841
        return (AE_BAD_PARAMETER);
1498 serge 842
    }
843
 
844
    CloseHandle (AcpiGbl_Semaphores[Index].OsHandle);
845
    AcpiGbl_Semaphores[Index].OsHandle = NULL;
2216 Serge 846
    return (AE_OK);
1498 serge 847
}
848
 
849
 
850
/******************************************************************************
851
 *
852
 * FUNCTION:    AcpiOsWaitSemaphore
853
 *
854
 * PARAMETERS:  Handle              - Handle returned by AcpiOsCreateSemaphore
855
 *              Units               - How many units to wait for
856
 *              Timeout             - How long to wait
857
 *
858
 * RETURN:      Status
859
 *
860
 * DESCRIPTION: Wait for units
861
 *
862
 *****************************************************************************/
863
 
864
ACPI_STATUS
865
AcpiOsWaitSemaphore (
866
    ACPI_SEMAPHORE      Handle,
867
    UINT32              Units,
868
    UINT16              Timeout)
869
{
870
    UINT32              Index = (UINT32) Handle;
871
    UINT32              WaitStatus;
872
    UINT32              OsTimeout = Timeout;
873
 
874
 
875
    ACPI_FUNCTION_ENTRY ();
876
 
877
 
878
    if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
879
        !AcpiGbl_Semaphores[Index].OsHandle)
880
    {
2216 Serge 881
        return (AE_BAD_PARAMETER);
1498 serge 882
    }
883
 
884
    if (Units > 1)
885
    {
886
        printf ("WaitSemaphore: Attempt to receive %u units\n", Units);
2216 Serge 887
        return (AE_NOT_IMPLEMENTED);
1498 serge 888
    }
889
 
890
    if (Timeout == ACPI_WAIT_FOREVER)
891
    {
892
        OsTimeout = INFINITE;
893
        if (AcpiGbl_DebugTimeout)
894
        {
895
            /* The debug timeout will prevent hang conditions */
896
 
897
            OsTimeout = ACPI_OS_DEBUG_TIMEOUT;
898
        }
899
    }
900
    else
901
    {
902
        /* Add 10ms to account for clock tick granularity */
903
 
904
        OsTimeout += 10;
905
    }
906
 
907
    WaitStatus = WaitForSingleObject (AcpiGbl_Semaphores[Index].OsHandle, OsTimeout);
908
    if (WaitStatus == WAIT_TIMEOUT)
909
    {
910
        if (AcpiGbl_DebugTimeout)
911
        {
912
            ACPI_EXCEPTION ((AE_INFO, AE_TIME,
913
                "Debug timeout on semaphore 0x%04X (%ums)\n",
914
                Index, ACPI_OS_DEBUG_TIMEOUT));
915
        }
2216 Serge 916
        return (AE_TIME);
1498 serge 917
    }
918
 
919
    if (AcpiGbl_Semaphores[Index].CurrentUnits == 0)
920
    {
921
        ACPI_ERROR ((AE_INFO, "%s - No unit received. Timeout 0x%X, OS_Status 0x%X",
922
            AcpiUtGetMutexName (Index), Timeout, WaitStatus));
923
 
2216 Serge 924
        return (AE_OK);
1498 serge 925
    }
926
 
927
    AcpiGbl_Semaphores[Index].CurrentUnits--;
2216 Serge 928
    return (AE_OK);
1498 serge 929
}
930
 
931
 
932
/******************************************************************************
933
 *
934
 * FUNCTION:    AcpiOsSignalSemaphore
935
 *
936
 * PARAMETERS:  Handle              - Handle returned by AcpiOsCreateSemaphore
937
 *              Units               - Number of units to send
938
 *
939
 * RETURN:      Status
940
 *
941
 * DESCRIPTION: Send units
942
 *
943
 *****************************************************************************/
944
 
945
ACPI_STATUS
946
AcpiOsSignalSemaphore (
947
    ACPI_SEMAPHORE      Handle,
948
    UINT32              Units)
949
{
950
    UINT32              Index = (UINT32) Handle;
951
 
952
 
953
    ACPI_FUNCTION_ENTRY ();
954
 
955
 
956
    if (Index >= ACPI_OS_MAX_SEMAPHORES)
957
    {
958
        printf ("SignalSemaphore: Index/Handle out of range: %2.2X\n", Index);
2216 Serge 959
        return (AE_BAD_PARAMETER);
1498 serge 960
    }
961
 
962
    if (!AcpiGbl_Semaphores[Index].OsHandle)
963
    {
964
        printf ("SignalSemaphore: Null OS handle, Index %2.2X\n", Index);
2216 Serge 965
        return (AE_BAD_PARAMETER);
1498 serge 966
    }
967
 
968
    if (Units > 1)
969
    {
970
        printf ("SignalSemaphore: Attempt to signal %u units, Index %2.2X\n", Units, Index);
2216 Serge 971
        return (AE_NOT_IMPLEMENTED);
1498 serge 972
    }
973
 
974
    if ((AcpiGbl_Semaphores[Index].CurrentUnits + 1) >
975
        AcpiGbl_Semaphores[Index].MaxUnits)
976
    {
977
        ACPI_ERROR ((AE_INFO,
978
            "Oversignalled semaphore[%u]! Current %u Max %u",
979
            Index, AcpiGbl_Semaphores[Index].CurrentUnits,
980
            AcpiGbl_Semaphores[Index].MaxUnits));
981
 
982
        return (AE_LIMIT);
983
    }
984
 
985
    AcpiGbl_Semaphores[Index].CurrentUnits++;
986
    ReleaseSemaphore (AcpiGbl_Semaphores[Index].OsHandle, Units, NULL);
987
 
988
    return (AE_OK);
989
}
990
 
2216 Serge 991
#endif /* ACPI_SINGLE_THREADED */
1498 serge 992
 
993
 
2216 Serge 994
/******************************************************************************
995
 *
996
 * FUNCTION:    Spinlock interfaces
997
 *
998
 * DESCRIPTION: Map these interfaces to semaphore interfaces
999
 *
1000
 *****************************************************************************/
1001
 
1498 serge 1002
ACPI_STATUS
1003
AcpiOsCreateLock (
1004
    ACPI_SPINLOCK           *OutHandle)
1005
{
1006
    return (AcpiOsCreateSemaphore (1, 1, OutHandle));
1007
}
1008
 
1009
void
1010
AcpiOsDeleteLock (
1011
    ACPI_SPINLOCK           Handle)
1012
{
1013
    AcpiOsDeleteSemaphore (Handle);
1014
}
1015
 
1016
ACPI_CPU_FLAGS
1017
AcpiOsAcquireLock (
1018
    ACPI_SPINLOCK           Handle)
1019
{
1020
    AcpiOsWaitSemaphore (Handle, 1, 0xFFFF);
1021
    return (0);
1022
}
1023
 
1024
void
1025
AcpiOsReleaseLock (
1026
    ACPI_SPINLOCK           Handle,
1027
    ACPI_CPU_FLAGS          Flags)
1028
{
1029
    AcpiOsSignalSemaphore (Handle, 1);
1030
}
1031
 
1032
 
1033
#if ACPI_FUTURE_IMPLEMENTATION
1034
 
1035
/* Mutex interfaces, just implement with a semaphore */
1036
 
1037
ACPI_STATUS
1038
AcpiOsCreateMutex (
1039
    ACPI_MUTEX              *OutHandle)
1040
{
1041
    return (AcpiOsCreateSemaphore (1, 1, OutHandle));
1042
}
1043
 
1044
void
1045
AcpiOsDeleteMutex (
1046
    ACPI_MUTEX              Handle)
1047
{
1048
    AcpiOsDeleteSemaphore (Handle);
1049
}
1050
 
1051
ACPI_STATUS
1052
AcpiOsAcquireMutex (
1053
    ACPI_MUTEX              Handle,
1054
    UINT16                  Timeout)
1055
{
1056
    AcpiOsWaitSemaphore (Handle, 1, Timeout);
1057
    return (0);
1058
}
1059
 
1060
void
1061
AcpiOsReleaseMutex (
1062
    ACPI_MUTEX              Handle)
1063
{
1064
    AcpiOsSignalSemaphore (Handle, 1);
1065
}
1066
#endif
1067
 
1068
 
1069
/******************************************************************************
1070
 *
1071
 * FUNCTION:    AcpiOsInstallInterruptHandler
1072
 *
2216 Serge 1073
 * PARAMETERS:  InterruptNumber     - Level handler should respond to.
1074
 *              ServiceRoutine      - Address of the ACPI interrupt handler
1075
 *              Context             - User context
1498 serge 1076
 *
1077
 * RETURN:      Handle to the newly installed handler.
1078
 *
2216 Serge 1079
 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI
1498 serge 1080
 *              OS-independent handler.
1081
 *
1082
 *****************************************************************************/
1083
 
1084
UINT32
1085
AcpiOsInstallInterruptHandler (
1086
    UINT32                  InterruptNumber,
1087
    ACPI_OSD_HANDLER        ServiceRoutine,
1088
    void                    *Context)
1089
{
1090
 
2216 Serge 1091
    return (AE_OK);
1498 serge 1092
}
1093
 
1094
 
1095
/******************************************************************************
1096
 *
1097
 * FUNCTION:    AcpiOsRemoveInterruptHandler
1098
 *
2216 Serge 1099
 * PARAMETERS:  Handle              - Returned when handler was installed
1498 serge 1100
 *
1101
 * RETURN:      Status
1102
 *
1103
 * DESCRIPTION: Uninstalls an interrupt handler.
1104
 *
1105
 *****************************************************************************/
1106
 
1107
ACPI_STATUS
1108
AcpiOsRemoveInterruptHandler (
1109
    UINT32                  InterruptNumber,
1110
    ACPI_OSD_HANDLER        ServiceRoutine)
1111
{
1112
 
2216 Serge 1113
    return (AE_OK);
1498 serge 1114
}
1115
 
1116
 
1117
/******************************************************************************
1118
 *
1119
 * FUNCTION:    AcpiOsStall
1120
 *
2216 Serge 1121
 * PARAMETERS:  Microseconds        - Time to stall
1498 serge 1122
 *
2216 Serge 1123
 * RETURN:      None. Blocks until stall is completed.
1498 serge 1124
 *
1125
 * DESCRIPTION: Sleep at microsecond granularity
1126
 *
1127
 *****************************************************************************/
1128
 
1129
void
1130
AcpiOsStall (
2216 Serge 1131
    UINT32                  Microseconds)
1498 serge 1132
{
1133
 
2216 Serge 1134
    Sleep ((Microseconds / 1000) + 1);
1498 serge 1135
    return;
1136
}
1137
 
1138
 
1139
/******************************************************************************
1140
 *
1141
 * FUNCTION:    AcpiOsSleep
1142
 *
2216 Serge 1143
 * PARAMETERS:  Milliseconds        - Time to sleep
1498 serge 1144
 *
2216 Serge 1145
 * RETURN:      None. Blocks until sleep is completed.
1498 serge 1146
 *
1147
 * DESCRIPTION: Sleep at millisecond granularity
1148
 *
1149
 *****************************************************************************/
1150
 
1151
void
1152
AcpiOsSleep (
2216 Serge 1153
    UINT64                  Milliseconds)
1498 serge 1154
{
1155
 
1156
    /* Add 10ms to account for clock tick granularity */
1157
 
2216 Serge 1158
    Sleep (((unsigned long) Milliseconds) + 10);
1498 serge 1159
    return;
1160
}
1161
 
1162
 
1163
/******************************************************************************
1164
 *
1165
 * FUNCTION:    AcpiOsReadPciConfiguration
1166
 *
2216 Serge 1167
 * PARAMETERS:  PciId               - Seg/Bus/Dev
1168
 *              Register            - Device Register
1169
 *              Value               - Buffer where value is placed
1170
 *              Width               - Number of bits
1498 serge 1171
 *
1172
 * RETURN:      Status
1173
 *
1174
 * DESCRIPTION: Read data from PCI configuration space
1175
 *
1176
 *****************************************************************************/
1177
 
1178
ACPI_STATUS
1179
AcpiOsReadPciConfiguration (
1180
    ACPI_PCI_ID             *PciId,
1181
    UINT32                  Register,
2216 Serge 1182
    UINT64                  *Value,
1498 serge 1183
    UINT32                  Width)
1184
{
1185
 
1186
    return (AE_OK);
1187
}
1188
 
1189
 
1190
/******************************************************************************
1191
 *
1192
 * FUNCTION:    AcpiOsWritePciConfiguration
1193
 *
2216 Serge 1194
 * PARAMETERS:  PciId               - Seg/Bus/Dev
1195
 *              Register            - Device Register
1196
 *              Value               - Value to be written
1197
 *              Width               - Number of bits
1498 serge 1198
 *
2216 Serge 1199
 * RETURN:      Status
1498 serge 1200
 *
1201
 * DESCRIPTION: Write data to PCI configuration space
1202
 *
1203
 *****************************************************************************/
1204
 
1205
ACPI_STATUS
1206
AcpiOsWritePciConfiguration (
1207
    ACPI_PCI_ID             *PciId,
1208
    UINT32                  Register,
1209
    UINT64                  Value,
1210
    UINT32                  Width)
1211
{
1212
 
1213
    return (AE_OK);
1214
}
1215
 
1216
 
1217
/******************************************************************************
1218
 *
1219
 * FUNCTION:    AcpiOsReadPort
1220
 *
2216 Serge 1221
 * PARAMETERS:  Address             - Address of I/O port/register to read
1222
 *              Value               - Where value is placed
1223
 *              Width               - Number of bits
1498 serge 1224
 *
1225
 * RETURN:      Value read from port
1226
 *
1227
 * DESCRIPTION: Read data from an I/O port or register
1228
 *
1229
 *****************************************************************************/
1230
 
1231
ACPI_STATUS
1232
AcpiOsReadPort (
1233
    ACPI_IO_ADDRESS         Address,
1234
    UINT32                  *Value,
1235
    UINT32                  Width)
1236
{
1237
 
1238
    switch (Width)
1239
    {
1240
    case 8:
1241
        *Value = 0xFF;
1242
        break;
1243
 
1244
    case 16:
1245
        *Value = 0xFFFF;
1246
        break;
1247
 
1248
    case 32:
1249
        *Value = 0xFFFFFFFF;
1250
        break;
1251
 
1252
    default:
1253
        return (AE_BAD_PARAMETER);
1254
    }
1255
 
1256
    return (AE_OK);
1257
}
1258
 
1259
 
1260
/******************************************************************************
1261
 *
1262
 * FUNCTION:    AcpiOsWritePort
1263
 *
2216 Serge 1264
 * PARAMETERS:  Address             - Address of I/O port/register to write
1265
 *              Value               - Value to write
1266
 *              Width               - Number of bits
1498 serge 1267
 *
1268
 * RETURN:      None
1269
 *
1270
 * DESCRIPTION: Write data to an I/O port or register
1271
 *
1272
 *****************************************************************************/
1273
 
1274
ACPI_STATUS
1275
AcpiOsWritePort (
1276
    ACPI_IO_ADDRESS         Address,
1277
    UINT32                  Value,
1278
    UINT32                  Width)
1279
{
1280
 
1281
    return (AE_OK);
1282
}
1283
 
1284
 
1285
/******************************************************************************
1286
 *
1287
 * FUNCTION:    AcpiOsReadMemory
1288
 *
2216 Serge 1289
 * PARAMETERS:  Address             - Physical Memory Address to read
1290
 *              Value               - Where value is placed
1291
 *              Width               - Number of bits
1498 serge 1292
 *
2216 Serge 1293
 * RETURN:      Value read from physical memory address. Always returned
1498 serge 1294
 *              as a 32-bit integer, regardless of the read width.
1295
 *
1296
 * DESCRIPTION: Read data from a physical memory address
1297
 *
1298
 *****************************************************************************/
1299
 
1300
ACPI_STATUS
1301
AcpiOsReadMemory (
1302
    ACPI_PHYSICAL_ADDRESS   Address,
1303
    UINT32                  *Value,
1304
    UINT32                  Width)
1305
{
1306
 
1307
    switch (Width)
1308
    {
1309
    case 8:
1310
    case 16:
1311
    case 32:
1312
        *Value = 0;
1313
        break;
1314
 
1315
    default:
1316
        return (AE_BAD_PARAMETER);
1317
        break;
1318
    }
1319
 
1320
    return (AE_OK);
1321
}
1322
 
1323
 
1324
/******************************************************************************
1325
 *
1326
 * FUNCTION:    AcpiOsWriteMemory
1327
 *
2216 Serge 1328
 * PARAMETERS:  Address             - Physical Memory Address to write
1329
 *              Value               - Value to write
1330
 *              Width               - Number of bits
1498 serge 1331
 *
1332
 * RETURN:      None
1333
 *
1334
 * DESCRIPTION: Write data to a physical memory address
1335
 *
1336
 *****************************************************************************/
1337
 
1338
ACPI_STATUS
1339
AcpiOsWriteMemory (
1340
    ACPI_PHYSICAL_ADDRESS   Address,
1341
    UINT32                  Value,
1342
    UINT32                  Width)
1343
{
1344
 
1345
    return (AE_OK);
1346
}
1347
 
1348
 
1349
/******************************************************************************
1350
 *
1351
 * FUNCTION:    AcpiOsSignal
1352
 *
2216 Serge 1353
 * PARAMETERS:  Function            - ACPI CA signal function code
1354
 *              Info                - Pointer to function-dependent structure
1498 serge 1355
 *
1356
 * RETURN:      Status
1357
 *
1358
 * DESCRIPTION: Miscellaneous functions. Example implementation only.
1359
 *
1360
 *****************************************************************************/
1361
 
1362
ACPI_STATUS
1363
AcpiOsSignal (
1364
    UINT32                  Function,
1365
    void                    *Info)
1366
{
1367
 
1368
    switch (Function)
1369
    {
1370
    case ACPI_SIGNAL_FATAL:
1371
        break;
1372
 
1373
    case ACPI_SIGNAL_BREAKPOINT:
1374
        break;
1375
 
1376
    default:
1377
        break;
1378
    }
1379
 
1380
    return (AE_OK);
1381
}
1382
 
1383
 
1384
/******************************************************************************
1385
 *
1386
 * FUNCTION:    Local cache interfaces
1387
 *
1388
 * DESCRIPTION: Implements cache interfaces via malloc/free for testing
1389
 *              purposes only.
1390
 *
1391
 *****************************************************************************/
1392
 
1393
#ifndef ACPI_USE_LOCAL_CACHE
1394
 
1395
ACPI_STATUS
1396
AcpiOsCreateCache (
1397
    char                    *CacheName,
1398
    UINT16                  ObjectSize,
1399
    UINT16                  MaxDepth,
1400
    ACPI_CACHE_T            **ReturnCache)
1401
{
1402
    ACPI_MEMORY_LIST        *NewCache;
1403
 
1404
 
1405
    NewCache = malloc (sizeof (ACPI_MEMORY_LIST));
1406
    if (!NewCache)
1407
    {
1408
        return (AE_NO_MEMORY);
1409
    }
1410
 
1411
    memset (NewCache, 0, sizeof (ACPI_MEMORY_LIST));
1412
    NewCache->LinkOffset = 8;
1413
    NewCache->ListName = CacheName;
1414
    NewCache->ObjectSize = ObjectSize;
1415
    NewCache->MaxDepth = MaxDepth;
1416
 
1417
    *ReturnCache = (ACPI_CACHE_T) NewCache;
1418
    return (AE_OK);
1419
}
1420
 
1421
ACPI_STATUS
1422
AcpiOsDeleteCache (
1423
    ACPI_CACHE_T            *Cache)
1424
{
1425
    free (Cache);
1426
    return (AE_OK);
1427
}
1428
 
1429
ACPI_STATUS
1430
AcpiOsPurgeCache (
1431
    ACPI_CACHE_T            *Cache)
1432
{
1433
    return (AE_OK);
1434
}
1435
 
1436
void *
1437
AcpiOsAcquireObject (
1438
    ACPI_CACHE_T            *Cache)
1439
{
1440
    void                    *NewObject;
1441
 
1442
    NewObject = malloc (((ACPI_MEMORY_LIST *) Cache)->ObjectSize);
1443
    memset (NewObject, 0, ((ACPI_MEMORY_LIST *) Cache)->ObjectSize);
1444
 
1445
    return (NewObject);
1446
}
1447
 
1448
ACPI_STATUS
1449
AcpiOsReleaseObject (
1450
    ACPI_CACHE_T            *Cache,
1451
    void                    *Object)
1452
{
1453
    free (Object);
1454
    return (AE_OK);
1455
}
1456
 
2216 Serge 1457
#endif /* ACPI_USE_LOCAL_CACHE */
1458
 
1459
 
1460
/* Optional multi-thread support */
1461
 
1462
#ifndef ACPI_SINGLE_THREADED
1463
/******************************************************************************
1464
 *
1465
 * FUNCTION:    AcpiOsGetThreadId
1466
 *
1467
 * PARAMETERS:  None
1468
 *
1469
 * RETURN:      Id of the running thread
1470
 *
1471
 * DESCRIPTION: Get the Id of the current (running) thread
1472
 *
1473
 *****************************************************************************/
1474
 
1475
ACPI_THREAD_ID
1476
AcpiOsGetThreadId (
1477
    void)
1478
{
1479
    DWORD                   ThreadId;
1480
 
1481
    /* Ensure ID is never 0 */
1482
 
1483
    ThreadId = GetCurrentThreadId ();
1484
    return ((ACPI_THREAD_ID) (ThreadId + 1));
1485
}
1486
 
1487
 
1488
/******************************************************************************
1489
 *
1490
 * FUNCTION:    AcpiOsExecute
1491
 *
1492
 * PARAMETERS:  Type                - Type of execution
1493
 *              Function            - Address of the function to execute
1494
 *              Context             - Passed as a parameter to the function
1495
 *
1496
 * RETURN:      Status
1497
 *
1498
 * DESCRIPTION: Execute a new thread
1499
 *
1500
 *****************************************************************************/
1501
 
1502
ACPI_STATUS
1503
AcpiOsExecute (
1504
    ACPI_EXECUTE_TYPE       Type,
1505
    ACPI_OSD_EXEC_CALLBACK  Function,
1506
    void                    *Context)
1507
{
1508
 
1509
    _beginthread (Function, (unsigned) 0, Context);
1510
    return (0);
1511
}
1512
 
1513
#endif /* ACPI_SINGLE_THREADED */
1514