Subversion Repositories Kolibri OS

Rev

Rev 1498 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1498 Rev 2216
Line 6... Line 6...
6
 
6
 
7
/******************************************************************************
7
/******************************************************************************
8
 *
8
 *
9
 * 1. Copyright Notice
9
 * 1. Copyright Notice
10
 *
10
 *
11
 * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
11
 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
12
 * All rights reserved.
12
 * All rights reserved.
13
 *
13
 *
14
 * 2. License
14
 * 2. License
15
 *
15
 *
Line 111... Line 111...
111
 * other governmental approval, or letter of assurance, without first obtaining
111
 * other governmental approval, or letter of assurance, without first obtaining
112
 * such license, approval or letter.
112
 * such license, approval or letter.
113
 *
113
 *
114
 *****************************************************************************/
114
 *****************************************************************************/
Line -... Line 115...
-
 
115
 
-
 
116
#include "acpi.h"
Line 115... Line 117...
115
 
117
#include "accommon.h"
116
 
118
 
Line 117... Line 119...
117
#ifdef WIN32
119
#ifdef WIN32
Line 128... Line 130...
128
#include 
130
#include 
129
#include 
131
#include 
130
#include 
132
#include 
131
#include 
133
#include 
Line 132... Line -...
132
 
-
 
133
#include "acpi.h"
-
 
134
#include "accommon.h"
-
 
135
 
134
 
136
#define _COMPONENT          ACPI_OS_SERVICES
135
#define _COMPONENT          ACPI_OS_SERVICES
Line 137... Line -...
137
        ACPI_MODULE_NAME    ("oswinxf")
-
 
138
 
-
 
139
 
-
 
140
/* Semaphore information structure */
-
 
141
 
-
 
142
typedef struct acpi_os_semaphore_info
136
        ACPI_MODULE_NAME    ("oswinxf")
143
{
137
 
144
    UINT16                  MaxUnits;
-
 
145
    UINT16                  CurrentUnits;
-
 
146
    void                    *OsHandle;
-
 
147
 
-
 
Line -... Line 138...
-
 
138
 
148
} ACPI_OS_SEMAPHORE_INFO;
139
extern FILE                 *AcpiGbl_DebugFile;
-
 
140
extern BOOLEAN              AcpiGbl_DebugTimeout;
Line 149... Line 141...
149
 
141
 
Line 150... Line 142...
150
/* Need enough semaphores to run the large aslts suite */
142
FILE                        *AcpiGbl_OutputFile;
Line 151... Line 143...
151
 
143
UINT64                      TimerFrequency;
152
#define ACPI_OS_MAX_SEMAPHORES  256
144
char                        TableName[ACPI_NAME_SIZE + 1];
153
 
145
 
Line 168... Line 160...
168
ACPI_TABLE_HEADER *
160
ACPI_TABLE_HEADER *
169
OsGetTable (
161
OsGetTable (
170
    char                    *Signature);
162
    char                    *Signature);
Line -... Line 163...
-
 
163
 
171
 
164
 
-
 
165
/*
172
 
166
 * Real semaphores are only used for a multi-threaded application
Line 173... Line -...
173
extern FILE                 *AcpiGbl_DebugFile;
-
 
174
extern BOOLEAN              AcpiGbl_DebugTimeout;
167
 */
175
 
-
 
Line -... Line 168...
-
 
168
#ifndef ACPI_SINGLE_THREADED
-
 
169
 
-
 
170
/* Semaphore information structure */
-
 
171
 
-
 
172
typedef struct acpi_os_semaphore_info
-
 
173
{
-
 
174
    UINT16                  MaxUnits;
-
 
175
    UINT16                  CurrentUnits;
-
 
176
    void                    *OsHandle;
-
 
177
 
176
FILE                        *AcpiGbl_OutputFile;
178
} ACPI_OS_SEMAPHORE_INFO;
-
 
179
 
-
 
180
/* Need enough semaphores to run the large aslts suite */
-
 
181
 
-
 
182
#define ACPI_OS_MAX_SEMAPHORES  256
Line 177... Line 183...
177
UINT64                      TimerFrequency;
183
 
178
char                        TableName[ACPI_NAME_SIZE + 1];
184
ACPI_OS_SEMAPHORE_INFO          AcpiGbl_Semaphores[ACPI_OS_MAX_SEMAPHORES];
179
 
185
 
180
#define ACPI_OS_DEBUG_TIMEOUT   30000 /* 30 seconds */
186
#endif /* ACPI_SINGLE_THREADED */
181
 
187
 
182
 
188
 
183
/******************************************************************************
189
/******************************************************************************
184
 *
190
 *
185
 * FUNCTION:    AcpiOsTerminate
191
 * FUNCTION:    AcpiOsTerminate
186
 *
192
 *
187
 * PARAMETERS:  None
193
 * PARAMETERS:  None
Line 188... Line 194...
188
 *
194
 *
189
 * RETURN:      None
195
 * RETURN:      Status
-
 
196
 *
190
 *
197
 * DESCRIPTION: Nothing to do for windows
191
 * DESCRIPTION: Nothing to do for windows
198
 *
192
 *
199
 *****************************************************************************/
Line 193... Line 200...
193
 *****************************************************************************/
200
 
194
 
201
ACPI_STATUS
Line 210... Line 217...
210
 * DESCRIPTION: Init this OSL
217
 * DESCRIPTION: Init this OSL
211
 *
218
 *
212
 *****************************************************************************/
219
 *****************************************************************************/
Line 213... Line 220...
213
 
220
 
214
ACPI_STATUS
221
ACPI_STATUS
-
 
222
AcpiOsInitialize (
215
AcpiOsInitialize (void)
223
    void)
216
{
224
{
Line 217... Line 225...
217
    LARGE_INTEGER           LocalTimerFrequency;
225
    LARGE_INTEGER           LocalTimerFrequency;
218
 
-
 
219
 
226
 
Line 220... Line 227...
220
    AcpiGbl_OutputFile = stdout;
227
 
-
 
228
#ifndef ACPI_SINGLE_THREADED
-
 
229
    /* Clear the semaphore info array */
-
 
230
 
Line 221... Line 231...
221
 
231
    memset (AcpiGbl_Semaphores, 0x00, sizeof (AcpiGbl_Semaphores));
Line 222... Line 232...
222
    /* Clear the semaphore info array */
232
#endif
223
 
233
 
Line 231... Line 241...
231
        /* Frequency is in ticks per second */
241
        /* Frequency is in ticks per second */
Line 232... Line 242...
232
 
242
 
233
        TimerFrequency = LocalTimerFrequency.QuadPart;
243
        TimerFrequency = LocalTimerFrequency.QuadPart;
Line 234... Line 244...
234
    }
244
    }
235
 
245
 
Line 236... Line 246...
236
    return AE_OK;
246
    return (AE_OK);
237
}
247
}
Line 458... Line 468...
458
 
468
 
459
/******************************************************************************
469
/******************************************************************************
460
 *
470
 *
461
 * FUNCTION:    AcpiOsPrintf
471
 * FUNCTION:    AcpiOsPrintf
462
 *
472
 *
463
 * PARAMETERS:  fmt, ...            Standard printf format
473
 * PARAMETERS:  Fmt, ...            - Standard printf format
464
 *
474
 *
465
 * RETURN:      None
475
 * RETURN:      None
466
 *
476
 *
467
 * DESCRIPTION: Formatted output
477
 * DESCRIPTION: Formatted output
Line 487... Line 497...
487
 
497
 
488
/******************************************************************************
498
/******************************************************************************
489
 *
499
 *
490
 * FUNCTION:    AcpiOsVprintf
500
 * FUNCTION:    AcpiOsVprintf
491
 *
501
 *
492
 * PARAMETERS:  fmt                 Standard printf format
502
 * PARAMETERS:  Fmt                 - Standard printf format
493
 *              args                Argument list
503
 *              Args                - Argument list
494
 *
504
 *
495
 * RETURN:      None
505
 * RETURN:      None
496
 *
506
 *
497
 * DESCRIPTION: Formatted output with argument list pointer
507
 * DESCRIPTION: Formatted output with argument list pointer
Line 537... Line 547...
537
 
547
 
538
/******************************************************************************
548
/******************************************************************************
539
 *
549
 *
540
 * FUNCTION:    AcpiOsGetLine
550
 * FUNCTION:    AcpiOsGetLine
541
 *
551
 *
542
 * PARAMETERS:  fmt                 Standard printf format
552
 * PARAMETERS:  Buffer              - Where to return the command line
-
 
553
 *              BufferLength        - Maximum length of Buffer
543
 *              args                Argument list
554
 *              BytesRead           - Where the actual byte count is returned
544
 *
555
 *
545
 * RETURN:      Actual bytes read
556
 * RETURN:      Status and actual bytes read
546
 *
557
 *
547
 * DESCRIPTION: Formatted input with argument list pointer
558
 * DESCRIPTION: Formatted input with argument list pointer
548
 *
559
 *
Line 549... Line 560...
549
 *****************************************************************************/
560
 *****************************************************************************/
550
 
561
 
551
UINT32
562
ACPI_STATUS
-
 
563
AcpiOsGetLine (
-
 
564
    char                    *Buffer,
552
AcpiOsGetLine (
565
    UINT32                  BufferLength,
553
    char                    *Buffer)
566
    UINT32                  *BytesRead)
554
{
567
{
Line 555... Line 568...
555
    char                    Temp;
568
    char                    Temp;
556
    UINT32                  i;
569
    UINT32                  i;
-
 
570
 
-
 
571
 
-
 
572
    for (i = 0; ; i++)
-
 
573
    {
-
 
574
        if (i >= BufferLength)
557
 
575
        {
558
 
576
            return (AE_BUFFER_OVERFLOW);
559
    for (i = 0; ; i++)
577
        }
560
    {
578
 
561
        scanf ("%1c", &Temp);
579
        scanf ("%1c", &Temp);
Line 571... Line 589...
571
 
589
 
Line 572... Line 590...
572
    Buffer [i] = 0;
590
    Buffer [i] = 0;
Line -... Line 591...
-
 
591
 
-
 
592
    /* Return the number of bytes in the string */
-
 
593
 
-
 
594
    if (BytesRead)
573
 
595
    {
574
    /* Return the number of bytes in the string */
596
        *BytesRead = i;
Line 575... Line 597...
575
 
597
    }
576
    return (i);
598
    return (AE_OK);
577
}
599
}
578
 
600
 
579
 
601
 
580
/******************************************************************************
602
/******************************************************************************
581
 *
603
 *
582
 * FUNCTION:    AcpiOsMapMemory
604
 * FUNCTION:    AcpiOsMapMemory
583
 *
605
 *
584
 * PARAMETERS:  where               Physical address of memory to be mapped
606
 * PARAMETERS:  Where               - Physical address of memory to be mapped
585
 *              length              How much memory to map
607
 *              Length              - How much memory to map
586
 *
608
 *
Line 587... Line 609...
587
 * RETURN:      Pointer to mapped memory.  Null on error.
609
 * RETURN:      Pointer to mapped memory. Null on error.
588
 *
610
 *
589
 * DESCRIPTION: Map physical memory into caller's address space
611
 * DESCRIPTION: Map physical memory into caller's address space
590
 *
612
 *
591
 *****************************************************************************/
613
 *****************************************************************************/
Line 592... Line 614...
592
 
614
 
593
void *
615
void *
Line 594... Line 616...
594
AcpiOsMapMemory (
616
AcpiOsMapMemory (
595
    ACPI_PHYSICAL_ADDRESS   where,
617
    ACPI_PHYSICAL_ADDRESS   Where,
596
    ACPI_SIZE               length)
618
    ACPI_SIZE               Length)
597
{
619
{
598
 
620
 
599
    return (ACPI_TO_POINTER ((ACPI_SIZE) where));
621
    return (ACPI_TO_POINTER ((ACPI_SIZE) Where));
600
}
622
}
601
 
623
 
602
 
624
 
603
/******************************************************************************
625
/******************************************************************************
604
 *
626
 *
605
 * FUNCTION:    AcpiOsUnmapMemory
627
 * FUNCTION:    AcpiOsUnmapMemory
606
 *
628
 *
Line 607... Line 629...
607
 * PARAMETERS:  where               Logical address of memory to be unmapped
629
 * PARAMETERS:  Where               - Logical address of memory to be unmapped
608
 *              length              How much memory to unmap
630
 *              Length              - How much memory to unmap
609
 *
631
 *
610
 * RETURN:      None.
632
 * RETURN:      None.
611
 *
633
 *
Line 612... Line 634...
612
 * DESCRIPTION: Delete a previously created mapping.  Where and Length must
634
 * DESCRIPTION: Delete a previously created mapping. Where and Length must
613
 *              correspond to a previous mapping exactly.
635
 *              correspond to a previous mapping exactly.
Line 614... Line 636...
614
 *
636
 *
615
 *****************************************************************************/
637
 *****************************************************************************/
616
 
638
 
617
void
639
void
618
AcpiOsUnmapMemory (
640
AcpiOsUnmapMemory (
619
    void                    *where,
641
    void                    *Where,
620
    ACPI_SIZE               length)
642
    ACPI_SIZE               Length)
621
{
643
{
622
 
644
 
623
    return;
645
    return;
624
}
646
}
Line 625... Line 647...
625
 
647
 
626
 
648
 
627
/******************************************************************************
649
/******************************************************************************
628
 *
650
 *
629
 * FUNCTION:    AcpiOsAllocate
651
 * FUNCTION:    AcpiOsAllocate
Line 630... Line 652...
630
 *
652
 *
Line 631... Line 653...
631
 * PARAMETERS:  Size                Amount to allocate, in bytes
653
 * PARAMETERS:  Size                - Amount to allocate, in bytes
632
 *
654
 *
Line 633... Line 655...
633
 * RETURN:      Pointer to the new allocation.  Null on error.
655
 * RETURN:      Pointer to the new allocation. Null on error.
634
 *
656
 *
635
 * DESCRIPTION: Allocate memory.  Algorithm is dependent on the OS.
657
 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS.
636
 *
658
 *
637
 *****************************************************************************/
659
 *****************************************************************************/
638
 
660
 
639
void *
661
void *
640
AcpiOsAllocate (
662
AcpiOsAllocate (
641
    ACPI_SIZE               size)
663
    ACPI_SIZE               Size)
642
{
664
{
Line 668... Line 690...
668
 
690
 
669
    free (Mem);
691
    free (Mem);
Line -... Line 692...
-
 
692
}
-
 
693
 
-
 
694
 
-
 
695
#ifdef ACPI_SINGLE_THREADED
-
 
696
/******************************************************************************
-
 
697
 *
-
 
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);
670
}
738
}
671
 
739
 
672
 
740
#else
673
/******************************************************************************
741
/******************************************************************************
674
 *
742
 *
Line 688... Line 756...
688
AcpiOsCreateSemaphore (
756
AcpiOsCreateSemaphore (
689
    UINT32              MaxUnits,
757
    UINT32              MaxUnits,
690
    UINT32              InitialUnits,
758
    UINT32              InitialUnits,
691
    ACPI_SEMAPHORE      *OutHandle)
759
    ACPI_SEMAPHORE      *OutHandle)
692
{
760
{
693
#ifdef _MULTI_THREADED
-
 
694
    void                *Mutex;
761
    void                *Mutex;
695
    UINT32              i;
762
    UINT32              i;
Line 696... Line 763...
696
 
763
 
697
    ACPI_FUNCTION_NAME (OsCreateSemaphore);
-
 
Line 698... Line 764...
698
#endif
764
    ACPI_FUNCTION_NAME (OsCreateSemaphore);
699
 
765
 
700
 
766
 
Line 708... Line 774...
708
        InitialUnits = MaxUnits;
774
        InitialUnits = MaxUnits;
709
    }
775
    }
Line 710... Line 776...
710
 
776
 
711
    if (InitialUnits > MaxUnits)
777
    if (InitialUnits > MaxUnits)
712
    {
778
    {
713
        return AE_BAD_PARAMETER;
779
        return (AE_BAD_PARAMETER);
Line 714... Line -...
714
    }
-
 
715
 
-
 
716
#ifdef _MULTI_THREADED
780
    }
Line 717... Line 781...
717
 
781
 
718
    /* Find an empty slot */
782
    /* Find an empty slot */
719
 
783
 
Line 726... Line 790...
726
    }
790
    }
727
    if (i >= ACPI_OS_MAX_SEMAPHORES)
791
    if (i >= ACPI_OS_MAX_SEMAPHORES)
728
    {
792
    {
729
        ACPI_EXCEPTION ((AE_INFO, AE_LIMIT,
793
        ACPI_EXCEPTION ((AE_INFO, AE_LIMIT,
730
            "Reached max semaphores (%u), could not create", ACPI_OS_MAX_SEMAPHORES));
794
            "Reached max semaphores (%u), could not create", ACPI_OS_MAX_SEMAPHORES));
731
        return AE_LIMIT;
795
        return (AE_LIMIT);
732
    }
796
    }
Line 733... Line 797...
733
 
797
 
Line 734... Line 798...
734
    /* Create an OS semaphore */
798
    /* Create an OS semaphore */
735
 
799
 
736
    Mutex = CreateSemaphore (NULL, InitialUnits, MaxUnits, NULL);
800
    Mutex = CreateSemaphore (NULL, InitialUnits, MaxUnits, NULL);
737
    if (!Mutex)
801
    if (!Mutex)
738
    {
802
    {
739
        ACPI_ERROR ((AE_INFO, "Could not create semaphore"));
803
        ACPI_ERROR ((AE_INFO, "Could not create semaphore"));
Line 740... Line 804...
740
        return AE_NO_MEMORY;
804
        return (AE_NO_MEMORY);
741
    }
805
    }
742
 
806
 
Line 743... Line 807...
743
    AcpiGbl_Semaphores[i].MaxUnits = (UINT16) MaxUnits;
807
    AcpiGbl_Semaphores[i].MaxUnits = (UINT16) MaxUnits;
744
    AcpiGbl_Semaphores[i].CurrentUnits = (UINT16) InitialUnits;
808
    AcpiGbl_Semaphores[i].CurrentUnits = (UINT16) InitialUnits;
Line 745... Line 809...
745
    AcpiGbl_Semaphores[i].OsHandle = Mutex;
809
    AcpiGbl_Semaphores[i].OsHandle = Mutex;
746
 
-
 
747
    ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Handle=%u, Max=%u, Current=%u, OsHandle=%p\n",
-
 
748
            i, MaxUnits, InitialUnits, Mutex));
810
 
749
 
811
    ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Handle=%u, Max=%u, Current=%u, OsHandle=%p\n",
Line 750... Line 812...
750
    *OutHandle = (void *) i;
812
            i, MaxUnits, InitialUnits, Mutex));
751
#endif
813
 
Line 774... Line 836...
774
 
836
 
775
 
837
 
776
    if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
838
    if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
777
        !AcpiGbl_Semaphores[Index].OsHandle)
839
        !AcpiGbl_Semaphores[Index].OsHandle)
778
    {
840
    {
Line 779... Line -...
779
        return AE_BAD_PARAMETER;
-
 
780
    }
-
 
781
 
-
 
782
 
841
        return (AE_BAD_PARAMETER);
783
#ifdef _MULTI_THREADED
842
    }
784
 
-
 
785
    CloseHandle (AcpiGbl_Semaphores[Index].OsHandle);
-
 
786
    AcpiGbl_Semaphores[Index].OsHandle = NULL;
843
 
787
#endif
844
    CloseHandle (AcpiGbl_Semaphores[Index].OsHandle);
Line 788... Line 845...
788
 
845
    AcpiGbl_Semaphores[Index].OsHandle = NULL;
789
    return AE_OK;
846
    return (AE_OK);
Line 808... Line 865...
808
AcpiOsWaitSemaphore (
865
AcpiOsWaitSemaphore (
809
    ACPI_SEMAPHORE      Handle,
866
    ACPI_SEMAPHORE      Handle,
810
    UINT32              Units,
867
    UINT32              Units,
811
    UINT16              Timeout)
868
    UINT16              Timeout)
812
{
869
{
813
#ifdef _MULTI_THREADED
-
 
814
    UINT32              Index = (UINT32) Handle;
870
    UINT32              Index = (UINT32) Handle;
815
    UINT32              WaitStatus;
871
    UINT32              WaitStatus;
816
    UINT32              OsTimeout = Timeout;
872
    UINT32              OsTimeout = Timeout;
Line 820... Line 876...
820
 
876
 
821
 
877
 
822
    if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
878
    if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
823
        !AcpiGbl_Semaphores[Index].OsHandle)
879
        !AcpiGbl_Semaphores[Index].OsHandle)
824
    {
880
    {
Line 825... Line 881...
825
        return AE_BAD_PARAMETER;
881
        return (AE_BAD_PARAMETER);
826
    }
882
    }
827
 
883
 
828
    if (Units > 1)
884
    if (Units > 1)
829
    {
885
    {
Line 830... Line 886...
830
        printf ("WaitSemaphore: Attempt to receive %u units\n", Units);
886
        printf ("WaitSemaphore: Attempt to receive %u units\n", Units);
831
        return AE_NOT_IMPLEMENTED;
887
        return (AE_NOT_IMPLEMENTED);
832
    }
888
    }
Line 855... Line 911...
855
        {
911
        {
856
            ACPI_EXCEPTION ((AE_INFO, AE_TIME,
912
            ACPI_EXCEPTION ((AE_INFO, AE_TIME,
857
                "Debug timeout on semaphore 0x%04X (%ums)\n",
913
                "Debug timeout on semaphore 0x%04X (%ums)\n",
858
                Index, ACPI_OS_DEBUG_TIMEOUT));
914
                Index, ACPI_OS_DEBUG_TIMEOUT));
859
        }
915
        }
860
        return AE_TIME;
916
        return (AE_TIME);
861
    }
917
    }
Line 862... Line 918...
862
 
918
 
863
    if (AcpiGbl_Semaphores[Index].CurrentUnits == 0)
919
    if (AcpiGbl_Semaphores[Index].CurrentUnits == 0)
864
    {
920
    {
865
        ACPI_ERROR ((AE_INFO, "%s - No unit received. Timeout 0x%X, OS_Status 0x%X",
921
        ACPI_ERROR ((AE_INFO, "%s - No unit received. Timeout 0x%X, OS_Status 0x%X",
Line 866... Line 922...
866
            AcpiUtGetMutexName (Index), Timeout, WaitStatus));
922
            AcpiUtGetMutexName (Index), Timeout, WaitStatus));
867
 
923
 
Line 868... Line 924...
868
        return AE_OK;
924
        return (AE_OK);
869
    }
-
 
870
 
-
 
871
    AcpiGbl_Semaphores[Index].CurrentUnits--;
925
    }
872
#endif
926
 
Line 873... Line 927...
873
 
927
    AcpiGbl_Semaphores[Index].CurrentUnits--;
874
    return AE_OK;
928
    return (AE_OK);
Line 891... Line 945...
891
ACPI_STATUS
945
ACPI_STATUS
892
AcpiOsSignalSemaphore (
946
AcpiOsSignalSemaphore (
893
    ACPI_SEMAPHORE      Handle,
947
    ACPI_SEMAPHORE      Handle,
894
    UINT32              Units)
948
    UINT32              Units)
895
{
949
{
896
#ifdef _MULTI_THREADED
-
 
897
 
-
 
898
    UINT32              Index = (UINT32) Handle;
950
    UINT32              Index = (UINT32) Handle;
Line 899... Line 951...
899
 
951
 
Line 900... Line 952...
900
 
952
 
901
    ACPI_FUNCTION_ENTRY ();
953
    ACPI_FUNCTION_ENTRY ();
902
 
954
 
903
 
955
 
904
    if (Index >= ACPI_OS_MAX_SEMAPHORES)
956
    if (Index >= ACPI_OS_MAX_SEMAPHORES)
Line 905... Line 957...
905
    {
957
    {
906
        printf ("SignalSemaphore: Index/Handle out of range: %2.2X\n", Index);
958
        printf ("SignalSemaphore: Index/Handle out of range: %2.2X\n", Index);
907
        return AE_BAD_PARAMETER;
959
        return (AE_BAD_PARAMETER);
908
    }
960
    }
909
 
961
 
Line 910... Line 962...
910
    if (!AcpiGbl_Semaphores[Index].OsHandle)
962
    if (!AcpiGbl_Semaphores[Index].OsHandle)
911
    {
963
    {
912
        printf ("SignalSemaphore: Null OS handle, Index %2.2X\n", Index);
964
        printf ("SignalSemaphore: Null OS handle, Index %2.2X\n", Index);
913
        return AE_BAD_PARAMETER;
965
        return (AE_BAD_PARAMETER);
914
    }
966
    }
Line 915... Line 967...
915
 
967
 
916
    if (Units > 1)
968
    if (Units > 1)
917
    {
969
    {
Line 931... Line 983...
931
    }
983
    }
Line 932... Line 984...
932
 
984
 
933
    AcpiGbl_Semaphores[Index].CurrentUnits++;
985
    AcpiGbl_Semaphores[Index].CurrentUnits++;
Line 934... Line -...
934
    ReleaseSemaphore (AcpiGbl_Semaphores[Index].OsHandle, Units, NULL);
-
 
935
 
-
 
936
#endif
986
    ReleaseSemaphore (AcpiGbl_Semaphores[Index].OsHandle, Units, NULL);
937
 
987
 
Line -... Line 988...
-
 
988
    return (AE_OK);
Line -... Line 989...
-
 
989
}
-
 
990
 
-
 
991
#endif /* ACPI_SINGLE_THREADED */
-
 
992
 
-
 
993
 
938
    return (AE_OK);
994
/******************************************************************************
-
 
995
 *
-
 
996
 * FUNCTION:    Spinlock interfaces
Line 939... Line 997...
939
}
997
 *
940
 
998
 * DESCRIPTION: Map these interfaces to semaphore interfaces
941
 
999
 *
942
/* Spinlock interfaces, just implement with a semaphore */
1000
 *****************************************************************************/
Line 1010... Line 1068...
1010
 
1068
 
1011
/******************************************************************************
1069
/******************************************************************************
1012
 *
1070
 *
1013
 * FUNCTION:    AcpiOsInstallInterruptHandler
1071
 * FUNCTION:    AcpiOsInstallInterruptHandler
1014
 *
1072
 *
1015
 * PARAMETERS:  InterruptNumber     Level handler should respond to.
1073
 * PARAMETERS:  InterruptNumber     - Level handler should respond to.
1016
 *              Isr                 Address of the ACPI interrupt handler
1074
 *              ServiceRoutine      - Address of the ACPI interrupt handler
1017
 *              ExceptPtr           Where status is returned
1075
 *              Context             - User context
1018
 *
1076
 *
1019
 * RETURN:      Handle to the newly installed handler.
1077
 * RETURN:      Handle to the newly installed handler.
1020
 *
1078
 *
1021
 * DESCRIPTION: Install an interrupt handler.  Used to install the ACPI
1079
 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI
Line 1028... Line 1086...
1028
    UINT32                  InterruptNumber,
1086
    UINT32                  InterruptNumber,
1029
    ACPI_OSD_HANDLER        ServiceRoutine,
1087
    ACPI_OSD_HANDLER        ServiceRoutine,
1030
    void                    *Context)
1088
    void                    *Context)
1031
{
1089
{
Line 1032... Line 1090...
1032
 
1090
 
1033
    return AE_OK;
1091
    return (AE_OK);
Line 1034... Line 1092...
1034
}
1092
}
1035
 
1093
 
1036
 
1094
 
1037
/******************************************************************************
1095
/******************************************************************************
1038
 *
1096
 *
1039
 * FUNCTION:    AcpiOsRemoveInterruptHandler
1097
 * FUNCTION:    AcpiOsRemoveInterruptHandler
1040
 *
1098
 *
1041
 * PARAMETERS:  Handle              Returned when handler was installed
1099
 * PARAMETERS:  Handle              - Returned when handler was installed
1042
 *
1100
 *
1043
 * RETURN:      Status
1101
 * RETURN:      Status
Line 1050... Line 1108...
1050
AcpiOsRemoveInterruptHandler (
1108
AcpiOsRemoveInterruptHandler (
1051
    UINT32                  InterruptNumber,
1109
    UINT32                  InterruptNumber,
1052
    ACPI_OSD_HANDLER        ServiceRoutine)
1110
    ACPI_OSD_HANDLER        ServiceRoutine)
1053
{
1111
{
Line 1054... Line 1112...
1054
 
1112
 
1055
    return AE_OK;
-
 
1056
}
-
 
1057
 
-
 
1058
 
-
 
1059
/******************************************************************************
-
 
1060
 *
-
 
1061
 * FUNCTION:    AcpiOsGetThreadId
-
 
1062
 *
-
 
1063
 * PARAMETERS:  None
-
 
1064
 *
-
 
1065
 * RETURN:      Id of the running thread
-
 
1066
 *
-
 
1067
 * DESCRIPTION: Get the Id of the current (running) thread
-
 
1068
 *
-
 
1069
 *****************************************************************************/
-
 
1070
 
-
 
1071
ACPI_THREAD_ID
-
 
1072
AcpiOsGetThreadId (
-
 
1073
    void)
-
 
1074
{
-
 
1075
    DWORD                   ThreadId;
-
 
1076
 
-
 
1077
    /* Ensure ID is never 0 */
-
 
1078
 
-
 
1079
    ThreadId = GetCurrentThreadId ();
-
 
1080
    return (ThreadId + 1);
-
 
1081
}
-
 
1082
 
-
 
1083
 
-
 
1084
/******************************************************************************
-
 
1085
 *
-
 
1086
 * FUNCTION:    AcpiOsExecute
-
 
1087
 *
-
 
1088
 * PARAMETERS:  Type            - Type of execution
-
 
1089
 *              Function        - Address of the function to execute
-
 
1090
 *              Context         - Passed as a parameter to the function
-
 
1091
 *
-
 
1092
 * RETURN:      Status
-
 
1093
 *
-
 
1094
 * DESCRIPTION: Execute a new thread
-
 
1095
 *
-
 
1096
 *****************************************************************************/
-
 
1097
 
-
 
1098
ACPI_STATUS
-
 
1099
AcpiOsExecute (
-
 
1100
    ACPI_EXECUTE_TYPE       Type,
-
 
1101
    ACPI_OSD_EXEC_CALLBACK  Function,
-
 
1102
    void                    *Context)
-
 
1103
{
-
 
1104
 
-
 
1105
#ifdef _MULTI_THREADED
-
 
1106
    _beginthread (Function, (unsigned) 0, Context);
-
 
1107
#endif
-
 
1108
 
-
 
1109
    return 0;
1113
    return (AE_OK);
Line 1110... Line 1114...
1110
}
1114
}
1111
 
1115
 
1112
 
1116
 
1113
/******************************************************************************
1117
/******************************************************************************
1114
 *
1118
 *
1115
 * FUNCTION:    AcpiOsStall
1119
 * FUNCTION:    AcpiOsStall
1116
 *
1120
 *
1117
 * PARAMETERS:  microseconds        To sleep
1121
 * PARAMETERS:  Microseconds        - Time to stall
1118
 *
1122
 *
1119
 * RETURN:      Blocks until sleep is completed.
1123
 * RETURN:      None. Blocks until stall is completed.
1120
 *
1124
 *
Line 1121... Line 1125...
1121
 * DESCRIPTION: Sleep at microsecond granularity
1125
 * DESCRIPTION: Sleep at microsecond granularity
1122
 *
1126
 *
1123
 *****************************************************************************/
1127
 *****************************************************************************/
1124
 
1128
 
Line 1125... Line 1129...
1125
void
1129
void
1126
AcpiOsStall (
1130
AcpiOsStall (
1127
    UINT32                  microseconds)
1131
    UINT32                  Microseconds)
Line 1128... Line 1132...
1128
{
1132
{
1129
 
1133
 
1130
    Sleep ((microseconds / 1000) + 1);
1134
    Sleep ((Microseconds / 1000) + 1);
1131
    return;
1135
    return;
1132
}
1136
}
1133
 
1137
 
1134
 
1138
 
1135
/******************************************************************************
1139
/******************************************************************************
1136
 *
1140
 *
1137
 * FUNCTION:    AcpiOsSleep
1141
 * FUNCTION:    AcpiOsSleep
1138
 *
1142
 *
Line 1139... Line 1143...
1139
 * PARAMETERS:  milliseconds        To sleep
1143
 * PARAMETERS:  Milliseconds        - Time to sleep
1140
 *
1144
 *
1141
 * RETURN:      Blocks until sleep is completed.
1145
 * RETURN:      None. Blocks until sleep is completed.
1142
 *
1146
 *
Line 1143... Line 1147...
1143
 * DESCRIPTION: Sleep at millisecond granularity
1147
 * DESCRIPTION: Sleep at millisecond granularity
Line 1144... Line 1148...
1144
 *
1148
 *
1145
 *****************************************************************************/
1149
 *****************************************************************************/
1146
 
1150
 
Line 1147... Line 1151...
1147
void
1151
void
1148
AcpiOsSleep (
1152
AcpiOsSleep (
1149
    UINT64                  milliseconds)
-
 
1150
{
-
 
1151
 
-
 
1152
    /* Add 10ms to account for clock tick granularity */
-
 
1153
 
-
 
1154
    Sleep (((unsigned long) milliseconds) + 10);
-
 
1155
    return;
-
 
1156
}
-
 
1157
 
-
 
1158
 
-
 
1159
/******************************************************************************
-
 
1160
 *
-
 
1161
 * FUNCTION:    AcpiOsValidateInterface
-
 
1162
 *
-
 
1163
 * PARAMETERS:  Interface           - Requested interface to be validated
-
 
1164
 *
-
 
1165
 * RETURN:      AE_OK if interface is supported, AE_SUPPORT otherwise
-
 
1166
 *
-
 
1167
 * DESCRIPTION: Match an interface string to the interfaces supported by the
-
 
1168
 *              host. Strings originate from an AML call to the _OSI method.
-
 
1169
 *
-
 
1170
 *****************************************************************************/
-
 
1171
 
1153
    UINT64                  Milliseconds)
1172
ACPI_STATUS
1154
{
1173
AcpiOsValidateInterface (
1155
 
1174
    char                    *Interface)
1156
    /* Add 10ms to account for clock tick granularity */
1175
{
1157
 
1176
 
1158
    Sleep (((unsigned long) Milliseconds) + 10);
1177
    return (AE_SUPPORT);
1159
    return;
1178
}
1160
}
1179
 
1161
 
1180
 
1162
 
1181
/******************************************************************************
1163
/******************************************************************************
Line 1195... Line 1177...
1195
 
1177
 
1196
ACPI_STATUS
1178
ACPI_STATUS
1197
AcpiOsReadPciConfiguration (
1179
AcpiOsReadPciConfiguration (
1198
    ACPI_PCI_ID             *PciId,
1180
    ACPI_PCI_ID             *PciId,
1199
    UINT32                  Register,
1181
    UINT32                  Register,
1200
    void                    *Value,
1182
    UINT64                  *Value,
1201
    UINT32                  Width)
1183
    UINT32                  Width)
Line 1202... Line 1184...
1202
{
1184
{
1203
 
1185
 
Line 1207... Line 1189...
1207
 
1189
 
1208
/******************************************************************************
1190
/******************************************************************************
1209
 *
1191
 *
1210
 * FUNCTION:    AcpiOsWritePciConfiguration
1192
 * FUNCTION:    AcpiOsWritePciConfiguration
1211
 *
1193
 *
1212
 * PARAMETERS:  PciId               Seg/Bus/Dev
1194
 * PARAMETERS:  PciId               - Seg/Bus/Dev
1213
 *              Register            Device Register
1195
 *              Register            - Device Register
1214
 *              Value               Value to be written
1196
 *              Value               - Value to be written
1215
 *              Width               Number of bits
1197
 *              Width               - Number of bits
1216
 *
1198
 *
1217
 * RETURN:      Status.
1199
 * RETURN:      Status
1218
 *
1200
 *
1219
 * DESCRIPTION: Write data to PCI configuration space
1201
 * DESCRIPTION: Write data to PCI configuration space
1220
 *
1202
 *
Line 1229... Line 1211...
1229
{
1211
{
Line 1230... Line 1212...
1230
 
1212
 
1231
    return (AE_OK);
1213
    return (AE_OK);
Line 1232... Line -...
1232
}
-
 
1233
 
-
 
1234
/* TEMPORARY STUB FUNCTION */
-
 
1235
void
-
 
1236
AcpiOsDerivePciId(
-
 
1237
    ACPI_HANDLE             Device,
-
 
1238
    ACPI_HANDLE             Region,
-
 
1239
    ACPI_PCI_ID             **PciId)
-
 
1240
{
-
 
1241
 
-
 
1242
    return;
-
 
Line 1243... Line 1214...
1243
}
1214
}
1244
 
1215
 
1245
 
1216
 
1246
/******************************************************************************
1217
/******************************************************************************
1247
 *
1218
 *
1248
 * FUNCTION:    AcpiOsReadPort
1219
 * FUNCTION:    AcpiOsReadPort
1249
 *
1220
 *
1250
 * PARAMETERS:  Address             Address of I/O port/register to read
1221
 * PARAMETERS:  Address             - Address of I/O port/register to read
1251
 *              Value               Where value is placed
1222
 *              Value               - Where value is placed
1252
 *              Width               Number of bits
1223
 *              Width               - Number of bits
1253
 *
1224
 *
1254
 * RETURN:      Value read from port
1225
 * RETURN:      Value read from port
Line 1288... Line 1259...
1288
 
1259
 
1289
/******************************************************************************
1260
/******************************************************************************
1290
 *
1261
 *
1291
 * FUNCTION:    AcpiOsWritePort
1262
 * FUNCTION:    AcpiOsWritePort
1292
 *
1263
 *
1293
 * PARAMETERS:  Address             Address of I/O port/register to write
1264
 * PARAMETERS:  Address             - Address of I/O port/register to write
1294
 *              Value               Value to write
1265
 *              Value               - Value to write
1295
 *              Width               Number of bits
1266
 *              Width               - Number of bits
1296
 *
1267
 *
1297
 * RETURN:      None
1268
 * RETURN:      None
1298
 *
1269
 *
1299
 * DESCRIPTION: Write data to an I/O port or register
1270
 * DESCRIPTION: Write data to an I/O port or register
Line 1313... Line 1284...
1313
 
1284
 
1314
/******************************************************************************
1285
/******************************************************************************
1315
 *
1286
 *
1316
 * FUNCTION:    AcpiOsReadMemory
1287
 * FUNCTION:    AcpiOsReadMemory
1317
 *
1288
 *
1318
 * PARAMETERS:  Address             Physical Memory Address to read
1289
 * PARAMETERS:  Address             - Physical Memory Address to read
1319
 *              Value               Where value is placed
1290
 *              Value               - Where value is placed
1320
 *              Width               Number of bits
1291
 *              Width               - Number of bits
1321
 *
1292
 *
1322
 * RETURN:      Value read from physical memory address.  Always returned
1293
 * RETURN:      Value read from physical memory address. Always returned
1323
 *              as a 32-bit integer, regardless of the read width.
1294
 *              as a 32-bit integer, regardless of the read width.
1324
 *
1295
 *
Line 1352... Line 1323...
1352
 
1323
 
1353
/******************************************************************************
1324
/******************************************************************************
1354
 *
1325
 *
1355
 * FUNCTION:    AcpiOsWriteMemory
1326
 * FUNCTION:    AcpiOsWriteMemory
1356
 *
1327
 *
1357
 * PARAMETERS:  Address             Physical Memory Address to write
1328
 * PARAMETERS:  Address             - Physical Memory Address to write
1358
 *              Value               Value to write
1329
 *              Value               - Value to write
1359
 *              Width               Number of bits
1330
 *              Width               - Number of bits
1360
 *
1331
 *
1361
 * RETURN:      None
1332
 * RETURN:      None
1362
 *
1333
 *
1363
 * DESCRIPTION: Write data to a physical memory address
1334
 * DESCRIPTION: Write data to a physical memory address
Line 1377... Line 1348...
1377
 
1348
 
1378
/******************************************************************************
1349
/******************************************************************************
1379
 *
1350
 *
1380
 * FUNCTION:    AcpiOsSignal
1351
 * FUNCTION:    AcpiOsSignal
1381
 *
1352
 *
1382
 * PARAMETERS:  Function            ACPI CA signal function code
1353
 * PARAMETERS:  Function            - ACPI CA signal function code
1383
 *              Info                Pointer to function-dependent structure
1354
 *              Info                - Pointer to function-dependent structure
1384
 *
1355
 *
1385
 * RETURN:      Status
1356
 * RETURN:      Status
1386
 *
1357
 *
1387
 * DESCRIPTION: Miscellaneous functions. Example implementation only.
1358
 * DESCRIPTION: Miscellaneous functions. Example implementation only.
Line 1481... Line 1452...
1481
{
1452
{
1482
    free (Object);
1453
    free (Object);
1483
    return (AE_OK);
1454
    return (AE_OK);
1484
}
1455
}
Line -... Line 1456...
-
 
1456
 
-
 
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
1485
 
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 */